diff options
| author | Eli Zaretskii | 2007-04-03 09:50:08 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2007-04-03 09:50:08 +0000 |
| commit | 8a8af2a40e87434a49de12a6773de7dc5a4b15e7 (patch) | |
| tree | ca0de794a749cc54ee6a23d1607366ef8c09aecc | |
| parent | 814066452f1bad8c685c2077cdf074468d2ab6ef (diff) | |
| download | emacs-8a8af2a40e87434a49de12a6773de7dc5a4b15e7.tar.gz emacs-8a8af2a40e87434a49de12a6773de7dc5a4b15e7.zip | |
(Inline Functions): Describe more disadvantages of defsubst, and make advice
against it stronger.
| -rw-r--r-- | lispref/functions.texi | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lispref/functions.texi b/lispref/functions.texi index 045aa454c9c..eedfa8c124f 100644 --- a/lispref/functions.texi +++ b/lispref/functions.texi | |||
| @@ -1193,17 +1193,22 @@ function except for one thing: when you compile a call to the function, | |||
| 1193 | the function's definition is open-coded into the caller. | 1193 | the function's definition is open-coded into the caller. |
| 1194 | 1194 | ||
| 1195 | 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 |
| 1196 | has disadvantages. For one thing, it reduces flexibility; if you change | 1196 | has disadvantages. For one thing, it reduces flexibility; if you |
| 1197 | the definition of the function, calls already inlined still use the old | 1197 | change the definition of the function, calls already inlined still use |
| 1198 | definition until you recompile them. Since the flexibility of | 1198 | the old definition until you recompile them. |
| 1199 | redefining functions is an important feature of Emacs, you should not | ||
| 1200 | make a function inline unless its speed is really crucial. | ||
| 1201 | 1199 | ||
| 1202 | Another disadvantage is that making a large function inline can increase | 1200 | Another disadvantage is that making a large function inline can increase |
| 1203 | 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 |
| 1204 | advantage of inline functions is greatest for small functions, you | 1202 | advantage of inline functions is greatest for small functions, you |
| 1205 | generally should not make large functions inline. | 1203 | generally should not make large functions inline. |
| 1206 | 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. | ||
| 1211 | |||
| 1207 | 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 |
| 1208 | inline function would execute. (@xref{Macros}.) But the macro would be | 1213 | inline function would execute. (@xref{Macros}.) But the macro would be |
| 1209 | 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 |