diff options
| author | Richard M. Stallman | 1994-04-30 01:38:51 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-30 01:38:51 +0000 |
| commit | 78c71a989daf70e8efd0dd64f1bd367e60ada05f (patch) | |
| tree | b8f9f9ab85520149cabbac824fc7ab6ecd76e500 /lispref | |
| parent | f06df5635fed315912ad508adf9d1de5278a1c5f (diff) | |
| download | emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.tar.gz emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.zip | |
entered into RCS
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/compile.texi | 42 | ||||
| -rw-r--r-- | lispref/loading.texi | 61 |
2 files changed, 58 insertions, 45 deletions
diff --git a/lispref/compile.texi b/lispref/compile.texi index 38f2b8196f3..69b328fd905 100644 --- a/lispref/compile.texi +++ b/lispref/compile.texi | |||
| @@ -86,9 +86,9 @@ the @code{byte-compile} function. You can compile a whole file with | |||
| 86 | @code{byte-compile-file}, or several files with | 86 | @code{byte-compile-file}, or several files with |
| 87 | @code{byte-recompile-directory} or @code{batch-byte-compile}. | 87 | @code{byte-recompile-directory} or @code{batch-byte-compile}. |
| 88 | 88 | ||
| 89 | When you run the byte compiler, you may get warnings in a buffer called | 89 | When you run the byte compiler, you may get warnings in a buffer |
| 90 | @samp{*Compile-Log*}. These report usage in your program that suggest a | 90 | called @samp{*Compile-Log*}. These report things in your program that |
| 91 | problem, but are not necessarily erroneous. | 91 | suggest a problem but are not necessarily erroneous. |
| 92 | 92 | ||
| 93 | @cindex macro compilation | 93 | @cindex macro compilation |
| 94 | Be careful when byte-compiling code that uses macros. Macro calls are | 94 | Be careful when byte-compiling code that uses macros. Macro calls are |
| @@ -97,7 +97,7 @@ for proper compilation. For more details, see @ref{Compiling Macros}. | |||
| 97 | 97 | ||
| 98 | Normally, compiling a file does not evaluate the file's contents or | 98 | Normally, compiling a file does not evaluate the file's contents or |
| 99 | load the file. But it does execute any @code{require} calls at | 99 | load the file. But it does execute any @code{require} calls at |
| 100 | top-level in the file. One way to ensure that necessary macro | 100 | top level in the file. One way to ensure that necessary macro |
| 101 | definitions are available during compilation is to require the file that | 101 | definitions are available during compilation is to require the file that |
| 102 | defines them. @xref{Features}. | 102 | defines them. @xref{Features}. |
| 103 | 103 | ||
| @@ -201,7 +201,7 @@ The returned value of this command is unpredictable. | |||
| 201 | This function runs @code{byte-compile-file} on files specified on the | 201 | This function runs @code{byte-compile-file} on files specified on the |
| 202 | command line. This function must be used only in a batch execution of | 202 | command line. This function must be used only in a batch execution of |
| 203 | Emacs, as it kills Emacs on completion. An error in one file does not | 203 | Emacs, as it kills Emacs on completion. An error in one file does not |
| 204 | prevent processing of subsequent files. (The file which gets the error | 204 | prevent processing of subsequent files. (The file that gets the error |
| 205 | will not, of course, produce any compiled code.) | 205 | will not, of course, produce any compiled code.) |
| 206 | 206 | ||
| 207 | @example | 207 | @example |
| @@ -238,12 +238,13 @@ this way. | |||
| 238 | @end defspec | 238 | @end defspec |
| 239 | 239 | ||
| 240 | @defspec eval-when-compile body | 240 | @defspec eval-when-compile body |
| 241 | This form marks @var{body} to be evaluated at compile time @emph{only}. | 241 | This form marks @var{body} to be evaluated at compile time and not when |
| 242 | The result of evaluation by the compiler becomes a constant which | 242 | the compiled program is loaded. The result of evaluation by the |
| 243 | appears in the compiled program. When the program is interpreted, not | 243 | compiler becomes a constant which appears in the compiled program. When |
| 244 | compiled at all, @var{body} is evaluated normally. | 244 | the program is interpreted, not compiled at all, @var{body} is evaluated |
| 245 | normally. | ||
| 245 | 246 | ||
| 246 | At top-level, this is analogous to the Common Lisp idiom | 247 | At top level, this is analogous to the Common Lisp idiom |
| 247 | @code{(eval-when (compile eval) @dots{})}. Elsewhere, the Common Lisp | 248 | @code{(eval-when (compile eval) @dots{})}. Elsewhere, the Common Lisp |
| 248 | @samp{#.} reader macro (but not when interpreting) is closer to what | 249 | @samp{#.} reader macro (but not when interpreting) is closer to what |
| 249 | @code{eval-when-compile} does. | 250 | @code{eval-when-compile} does. |
| @@ -279,7 +280,8 @@ The list of argument symbols. | |||
| 279 | The string containing the byte-code instructions. | 280 | The string containing the byte-code instructions. |
| 280 | 281 | ||
| 281 | @item constants | 282 | @item constants |
| 282 | The vector of constants referenced by the byte code. | 283 | The vector of Lisp objects referenced by the byte code. These include |
| 284 | symbols used as function names and variable names. | ||
| 283 | 285 | ||
| 284 | @item stacksize | 286 | @item stacksize |
| 285 | The maximum stack size this function needs. | 287 | The maximum stack size this function needs. |
| @@ -318,7 +320,7 @@ with @var{elements} as its elements. | |||
| 318 | 320 | ||
| 319 | You should not try to come up with the elements for a byte-code | 321 | You should not try to come up with the elements for a byte-code |
| 320 | function yourself, because if they are inconsistent, Emacs may crash | 322 | function yourself, because if they are inconsistent, Emacs may crash |
| 321 | when you call the function. Always leave it to the byte-compiler to | 323 | when you call the function. Always leave it to the byte compiler to |
| 322 | create these objects; it makes the elements consistent (we hope). | 324 | create these objects; it makes the elements consistent (we hope). |
| 323 | 325 | ||
| 324 | You can access the elements of a byte-code object using @code{aref}; | 326 | You can access the elements of a byte-code object using @code{aref}; |
| @@ -336,11 +338,11 @@ form. | |||
| 336 | 338 | ||
| 337 | The byte-code interpreter is implemented as a simple stack machine. | 339 | The byte-code interpreter is implemented as a simple stack machine. |
| 338 | It pushes values onto a stack of its own, then pops them off to use them | 340 | It pushes values onto a stack of its own, then pops them off to use them |
| 339 | in calculations and push the result back on the stack. When a byte-code | 341 | in calculations whose results are themselves pushed back on the stack. |
| 340 | function returns, it pops a value off the stack and returns it as the | 342 | When a byte-code function returns, it pops a value off the stack and |
| 341 | value of the function. | 343 | returns it as the value of the function. |
| 342 | 344 | ||
| 343 | In addition to the stack, byte-code functions can use, bind and set | 345 | In addition to the stack, byte-code functions can use, bind, and set |
| 344 | ordinary Lisp variables, by transferring values between variables and | 346 | ordinary Lisp variables, by transferring values between variables and |
| 345 | the stack. | 347 | the stack. |
| 346 | 348 | ||
| @@ -442,7 +444,7 @@ they still serve their purpose. | |||
| 442 | 444 | ||
| 443 | @group | 445 | @group |
| 444 | ; @r{Stack now contains:} | 446 | ; @r{Stack now contains:} |
| 445 | ; @minus{} @r{result of result of recursive} | 447 | ; @minus{} @r{result of recursive} |
| 446 | ; @r{call to @code{factorial}} | 448 | ; @r{call to @code{factorial}} |
| 447 | ; @minus{} @r{value of @code{integer}} | 449 | ; @minus{} @r{value of @code{integer}} |
| 448 | ; @minus{} @r{@code{*}} | 450 | ; @minus{} @r{@code{*}} |
| @@ -537,10 +539,10 @@ The @code{silly-loop} function is somewhat more complex: | |||
| 537 | @end group | 539 | @end group |
| 538 | 540 | ||
| 539 | @group | 541 | @group |
| 540 | 9 goto-if-nil-else-pop 17 ; @r{Goto 17 if @code{n} > 0} | 542 | 9 goto-if-nil-else-pop 17 ; @r{Goto 17 if @code{n} <= 0} |
| 543 | ; @r{(this exits the while loop).} | ||
| 541 | ; @r{else pop top of stack} | 544 | ; @r{else pop top of stack} |
| 542 | ; @r{and continue} | 545 | ; @r{and continue} |
| 543 | ; @r{(this exits the while loop).} | ||
| 544 | @end group | 546 | @end group |
| 545 | 547 | ||
| 546 | @group | 548 | @group |
| @@ -563,6 +565,8 @@ The @code{silly-loop} function is somewhat more complex: | |||
| 563 | @group | 565 | @group |
| 564 | 17 discard ; @r{Discard result of while loop} | 566 | 17 discard ; @r{Discard result of while loop} |
| 565 | ; @r{by popping top of stack.} | 567 | ; @r{by popping top of stack.} |
| 568 | ; @r{This result is the value @code{nil} that} | ||
| 569 | ; @r{was not popped by the goto at 9.} | ||
| 566 | @end group | 570 | @end group |
| 567 | 571 | ||
| 568 | @group | 572 | @group |
diff --git a/lispref/loading.texi b/lispref/loading.texi index 59d27a0a13e..892473b9baf 100644 --- a/lispref/loading.texi +++ b/lispref/loading.texi | |||
| @@ -21,8 +21,8 @@ in an Emacs buffer. | |||
| 21 | 21 | ||
| 22 | @cindex top-level form | 22 | @cindex top-level form |
| 23 | The loaded file must contain Lisp expressions, either as source code | 23 | The loaded file must contain Lisp expressions, either as source code |
| 24 | or, optionally, as byte-compiled code. Each form in the file is called | 24 | or as byte-compiled code. Each form in the file is called a |
| 25 | a @dfn{top-level form}. There is no special format for the forms in a | 25 | @dfn{top-level form}. There is no special format for the forms in a |
| 26 | loadable file; any form in a file may equally well be typed directly | 26 | loadable file; any form in a file may equally well be typed directly |
| 27 | into a buffer and evaluated there. (Indeed, most code is tested this | 27 | into a buffer and evaluated there. (Indeed, most code is tested this |
| 28 | way.) Most often, the forms are function definitions and variable | 28 | way.) Most often, the forms are function definitions and variable |
| @@ -61,7 +61,7 @@ To find the file, @code{load} first looks for a file named | |||
| 61 | @file{@var{filename}.elc}, that is, for a file whose name is | 61 | @file{@var{filename}.elc}, that is, for a file whose name is |
| 62 | @var{filename} with @samp{.elc} appended. If such a file exists, it is | 62 | @var{filename} with @samp{.elc} appended. If such a file exists, it is |
| 63 | loaded. If there is no file by that name, then @code{load} looks for a | 63 | loaded. If there is no file by that name, then @code{load} looks for a |
| 64 | file names @file{@var{filename}.el}. If that file exists, it is loaded. | 64 | file named @file{@var{filename}.el}. If that file exists, it is loaded. |
| 65 | Finally, if neither of those names is found, @code{load} looks for a | 65 | Finally, if neither of those names is found, @code{load} looks for a |
| 66 | file named @var{filename} with nothing appended, and loads it if it | 66 | file named @var{filename} with nothing appended, and loads it if it |
| 67 | exists. (The @code{load} function is not clever about looking at | 67 | exists. (The @code{load} function is not clever about looking at |
| @@ -92,8 +92,8 @@ non-@code{nil}. | |||
| 92 | 92 | ||
| 93 | @cindex load errors | 93 | @cindex load errors |
| 94 | Any unhandled errors while loading a file terminate loading. If the | 94 | Any unhandled errors while loading a file terminate loading. If the |
| 95 | load was done for the sake of @code{autoload}, certain kinds of | 95 | load was done for the sake of @code{autoload}, any function definitions |
| 96 | top-level forms, those which define functions, are undone. | 96 | made during the loading are undone. |
| 97 | 97 | ||
| 98 | @kindex file-error | 98 | @kindex file-error |
| 99 | If @code{load} can't find the file to load, then normally it signals the | 99 | If @code{load} can't find the file to load, then normally it signals the |
| @@ -166,11 +166,12 @@ followed then by the @file{/user/bil/emacs} directory and then by | |||
| 166 | the @file{/usr/local/lisplib} directory, | 166 | the @file{/usr/local/lisplib} directory, |
| 167 | which are then followed by the standard directories for Lisp code. | 167 | which are then followed by the standard directories for Lisp code. |
| 168 | 168 | ||
| 169 | The command line options @samp{-l} or @samp{-load} specify Lispa library | 169 | The command line options @samp{-l} or @samp{-load} specify a Lisp |
| 170 | to load. Since this file might be in the current directory, Emacs 18 | 170 | library to load as part of Emacs startup. Since this file might be in |
| 171 | temporarily adds the current directory to the front of @code{load-path} | 171 | the current directory, Emacs 18 temporarily adds the current directory |
| 172 | so the file can be found there. Newer Emacs versions also find such | 172 | to the front of @code{load-path} so the file can be found there. Newer |
| 173 | files in the current directory, but without altering @code{load-path}. | 173 | Emacs versions also find such files in the current directory, but |
| 174 | without altering @code{load-path}. | ||
| 174 | @end defopt | 175 | @end defopt |
| 175 | 176 | ||
| 176 | @defvar load-in-progress | 177 | @defvar load-in-progress |
| @@ -202,8 +203,8 @@ for the command @code{update-file-autoloads}, which constructs calls to | |||
| 202 | comments are the most convenient way to make a function autoload, but | 203 | comments are the most convenient way to make a function autoload, but |
| 203 | only for packages installed along with Emacs. | 204 | only for packages installed along with Emacs. |
| 204 | 205 | ||
| 205 | @defun autoload symbol filename &optional docstring interactive type | 206 | @defun autoload function filename &optional docstring interactive type |
| 206 | This function defines the function (or macro) named @var{symbol} so as | 207 | This function defines the function (or macro) named @var{function} so as |
| 207 | to load automatically from @var{filename}. The string @var{filename} | 208 | to load automatically from @var{filename}. The string @var{filename} |
| 208 | specifies the file to load to get the real definition of @var{function}. | 209 | specifies the file to load to get the real definition of @var{function}. |
| 209 | 210 | ||
| @@ -227,9 +228,9 @@ keymap. Various parts of Emacs need to know this information without | |||
| 227 | loading the real definition. | 228 | loading the real definition. |
| 228 | 229 | ||
| 229 | @cindex function cell in autoload | 230 | @cindex function cell in autoload |
| 230 | If @var{symbol} already has a non-void function definition that is not | 231 | If @var{function} already has a non-void function definition that is not |
| 231 | an autoload object, @code{autoload} does nothing and returns @code{nil}. | 232 | an autoload object, @code{autoload} does nothing and returns @code{nil}. |
| 232 | If the function cell of @var{symbol} is void, or is already an autoload | 233 | If the function cell of @var{function} is void, or is already an autoload |
| 233 | object, then it is defined as an autoload object like this: | 234 | object, then it is defined as an autoload object like this: |
| 234 | 235 | ||
| 235 | @example | 236 | @example |
| @@ -278,11 +279,11 @@ autoloads for all files in the current directory. | |||
| 278 | The same magic comment can copy any kind of form into | 279 | The same magic comment can copy any kind of form into |
| 279 | @file{loaddefs.el}. If the form following the magic comment is not a | 280 | @file{loaddefs.el}. If the form following the magic comment is not a |
| 280 | function definition, it is copied verbatim. You can also use a magic | 281 | function definition, it is copied verbatim. You can also use a magic |
| 281 | comment to execute a form at build time executing it when the file | 282 | comment to execute a form at build time @emph{without} executing it when |
| 282 | itself is loaded. To do this, write the form @dfn{on the same line} as | 283 | the file itself is loaded. To do this, write the form @dfn{on the same |
| 283 | the magic comment. Since it is in a comment, it does nothing when you | 284 | line} as the magic comment. Since it is in a comment, it does nothing |
| 284 | load the source file; but @code{update-file-autoloads} copies it to | 285 | when you load the source file; but @code{update-file-autoloads} copies |
| 285 | @file{loaddefs.el}, where it is executed while building Emacs. | 286 | it to @file{loaddefs.el}, where it is executed while building Emacs. |
| 286 | 287 | ||
| 287 | The following example shows how @code{doctor} is prepared for | 288 | The following example shows how @code{doctor} is prepared for |
| 288 | autoloading with a magic comment: | 289 | autoloading with a magic comment: |
| @@ -367,7 +368,9 @@ has been loaded before: | |||
| 367 | @noindent | 368 | @noindent |
| 368 | If the library uses @code{provide} to provide a named feature, you can | 369 | If the library uses @code{provide} to provide a named feature, you can |
| 369 | use @code{featurep} to test whether the library has been loaded. | 370 | use @code{featurep} to test whether the library has been loaded. |
| 371 | @ifinfo | ||
| 370 | @xref{Features}. | 372 | @xref{Features}. |
| 373 | @end ifinfo | ||
| 371 | 374 | ||
| 372 | @node Features | 375 | @node Features |
| 373 | @section Features | 376 | @section Features |
| @@ -391,7 +394,7 @@ hasn't been loaded already. | |||
| 391 | feature name as argument. @code{require} looks in the global variable | 394 | feature name as argument. @code{require} looks in the global variable |
| 392 | @code{features} to see whether the desired feature has been provided | 395 | @code{features} to see whether the desired feature has been provided |
| 393 | already. If not, it loads the feature from the appropriate file. This | 396 | already. If not, it loads the feature from the appropriate file. This |
| 394 | file should call @code{provide} at the top-level to add the feature to | 397 | file should call @code{provide} at the top level to add the feature to |
| 395 | @code{features}; if it fails to do so, @code{require} signals an error. | 398 | @code{features}; if it fails to do so, @code{require} signals an error. |
| 396 | @cindex load error with require | 399 | @cindex load error with require |
| 397 | 400 | ||
| @@ -427,7 +430,7 @@ This adds @code{comint} to the global @code{features} list, so that | |||
| 427 | done. | 430 | done. |
| 428 | 431 | ||
| 429 | @cindex byte-compiling @code{require} | 432 | @cindex byte-compiling @code{require} |
| 430 | When @code{require} is used at top-level in a file, it takes effect | 433 | When @code{require} is used at top level in a file, it takes effect |
| 431 | when you byte-compile that file (@pxref{Byte Compilation}) as well as | 434 | when you byte-compile that file (@pxref{Byte Compilation}) as well as |
| 432 | when you load it. This is in case the required package contains macros | 435 | when you load it. This is in case the required package contains macros |
| 433 | that the byte compiler must know about. | 436 | that the byte compiler must know about. |
| @@ -446,6 +449,12 @@ feature, as in the following example. | |||
| 446 | @end group | 449 | @end group |
| 447 | @end smallexample | 450 | @end smallexample |
| 448 | 451 | ||
| 452 | @noindent | ||
| 453 | The compiler ignores the @code{provide}, then processes the | ||
| 454 | @code{require} by loading the file in question. Loading the file does | ||
| 455 | execute the @code{provide} call, so the subsequent @code{require} call | ||
| 456 | does nothing while loading. | ||
| 457 | |||
| 449 | @defun provide feature | 458 | @defun provide feature |
| 450 | This function announces that @var{feature} is now loaded, or being | 459 | This function announces that @var{feature} is now loaded, or being |
| 451 | loaded, into the current Emacs session. This means that the facilities | 460 | loaded, into the current Emacs session. This means that the facilities |
| @@ -508,10 +517,10 @@ reclaim memory for other Lisp objects. To do this, use the function | |||
| 508 | 517 | ||
| 509 | @deffn Command unload-feature feature | 518 | @deffn Command unload-feature feature |
| 510 | This command unloads the library that provided feature @var{feature}. | 519 | This command unloads the library that provided feature @var{feature}. |
| 511 | It undefines all functions and variables defined with @code{defvar}, | 520 | It undefines all functions, macros, and variables defined in that |
| 512 | @code{defmacro}, @code{defconst}, @code{defsubst} and @code{defalias} by | 521 | library with @code{defconst}, @code{defvar}, @code{defun}, |
| 513 | that library. It then restores any autoloads associated with those | 522 | @code{defmacro}, @code{defsubst} and @code{defalias}. It then restores |
| 514 | symbols. | 523 | any autoloads formerly associated with those symbols. |
| 515 | @end deffn | 524 | @end deffn |
| 516 | 525 | ||
| 517 | The @code{unload-feature} function is written in Lisp; its actions are | 526 | The @code{unload-feature} function is written in Lisp; its actions are |
| @@ -528,7 +537,7 @@ composed of these kinds of objects: | |||
| 528 | 537 | ||
| 529 | @itemize @bullet | 538 | @itemize @bullet |
| 530 | @item | 539 | @item |
| 531 | Symbols, which were defined as functions or variables. | 540 | Symbols that were defined by this library. |
| 532 | @item | 541 | @item |
| 533 | Lists of the form @code{(require . @var{feature})} indicating | 542 | Lists of the form @code{(require . @var{feature})} indicating |
| 534 | features that were required. | 543 | features that were required. |