Mercurial > emacs
comparison lispref/functions.texi @ 90796:4ef881a120fe
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 675-697)
- Update from CVS
- Merge from gnus--rel--5.10
- Release ERC 5.2.
* gnus--rel--5.10 (patch 211-215)
- Update from CVS
- Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-189
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 11 Apr 2007 00:17:47 +0000 |
parents | 95d0cdf160ea fba5b366a207 |
children |
comparison
equal
deleted
inserted
replaced
90795:b9182b6a90c9 | 90796:4ef881a120fe |
---|---|
291 @node Argument List | 291 @node Argument List |
292 @subsection Other Features of Argument Lists | 292 @subsection Other Features of Argument Lists |
293 @kindex wrong-number-of-arguments | 293 @kindex wrong-number-of-arguments |
294 @cindex argument binding | 294 @cindex argument binding |
295 @cindex binding arguments | 295 @cindex binding arguments |
296 @cindex argument lists, features | |
296 | 297 |
297 Our simple sample function, @code{(lambda (a b c) (+ a b c))}, | 298 Our simple sample function, @code{(lambda (a b c) (+ a b c))}, |
298 specifies three argument variables, so it must be called with three | 299 specifies three argument variables, so it must be called with three |
299 arguments: if you try to call it with only two arguments or four | 300 arguments: if you try to call it with only two arguments or four |
300 arguments, you get a @code{wrong-number-of-arguments} error. | 301 arguments, you get a @code{wrong-number-of-arguments} error. |
581 without any hesitation or notification. Redefining a function already | 582 without any hesitation or notification. Redefining a function already |
582 defined is often done deliberately, and there is no way to distinguish | 583 defined is often done deliberately, and there is no way to distinguish |
583 deliberate redefinition from unintentional redefinition. | 584 deliberate redefinition from unintentional redefinition. |
584 @end defspec | 585 @end defspec |
585 | 586 |
587 @cindex function aliases | |
586 @defun defalias name definition &optional docstring | 588 @defun defalias name definition &optional docstring |
587 @anchor{Definition of defalias} | 589 @anchor{Definition of defalias} |
588 This special form defines the symbol @var{name} as a function, with | 590 This special form defines the symbol @var{name} as a function, with |
589 definition @var{definition} (which can be any valid Lisp function). | 591 definition @var{definition} (which can be any valid Lisp function). |
590 It returns @var{definition}. | 592 It returns @var{definition}. |
1189 of @code{defun}. An inline function works just like an ordinary | 1191 of @code{defun}. An inline function works just like an ordinary |
1190 function except for one thing: when you compile a call to the function, | 1192 function except for one thing: when you compile a call to the function, |
1191 the function's definition is open-coded into the caller. | 1193 the function's definition is open-coded into the caller. |
1192 | 1194 |
1193 Making a function inline makes explicit calls run faster. But it also | 1195 Making a function inline makes explicit calls run faster. But it also |
1194 has disadvantages. For one thing, it reduces flexibility; if you change | 1196 has disadvantages. For one thing, it reduces flexibility; if you |
1195 the definition of the function, calls already inlined still use the old | 1197 change the definition of the function, calls already inlined still use |
1196 definition until you recompile them. Since the flexibility of | 1198 the old definition until you recompile them. |
1197 redefining functions is an important feature of Emacs, you should not | |
1198 make a function inline unless its speed is really crucial. | |
1199 | 1199 |
1200 Another disadvantage is that making a large function inline can increase | 1200 Another disadvantage is that making a large function inline can increase |
1201 the size of compiled code both in files and in memory. Since the speed | 1201 the size of compiled code both in files and in memory. Since the speed |
1202 advantage of inline functions is greatest for small functions, you | 1202 advantage of inline functions is greatest for small functions, you |
1203 generally should not make large functions inline. | 1203 generally should not make large functions inline. |
1204 | |
1205 Also, inline functions do not behave well with respect to debugging, | |
1206 tracing, and advising (@pxref{Advising Functions}). Since ease of | |
1207 debugging and the flexibility of redefining functions are important | |
1208 features of Emacs, you should not make a function inline, even if it's | |
1209 small, unless its speed is really crucial, and you've timed the code | |
1210 to verify that using @code{defun} actually has performance problems. | |
1204 | 1211 |
1205 It's possible to define a macro to expand into the same code that an | 1212 It's possible to define a macro to expand into the same code that an |
1206 inline function would execute. (@xref{Macros}.) But the macro would be | 1213 inline function would execute. (@xref{Macros}.) But the macro would be |
1207 limited to direct use in expressions---a macro cannot be called with | 1214 limited to direct use in expressions---a macro cannot be called with |
1208 @code{apply}, @code{mapcar} and so on. Also, it takes some work to | 1215 @code{apply}, @code{mapcar} and so on. Also, it takes some work to |