aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorRichard M. Stallman1994-04-30 01:38:51 +0000
committerRichard M. Stallman1994-04-30 01:38:51 +0000
commit78c71a989daf70e8efd0dd64f1bd367e60ada05f (patch)
treeb8f9f9ab85520149cabbac824fc7ab6ecd76e500 /lispref
parentf06df5635fed315912ad508adf9d1de5278a1c5f (diff)
downloademacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.tar.gz
emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.zip
entered into RCS
Diffstat (limited to 'lispref')
-rw-r--r--lispref/compile.texi42
-rw-r--r--lispref/loading.texi61
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 90called @samp{*Compile-Log*}. These report things in your program that
91problem, but are not necessarily erroneous. 91suggest 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
99load the file. But it does execute any @code{require} calls at 99load the file. But it does execute any @code{require} calls at
100top-level in the file. One way to ensure that necessary macro 100top level in the file. One way to ensure that necessary macro
101definitions are available during compilation is to require the file that 101definitions are available during compilation is to require the file that
102defines them. @xref{Features}. 102defines them. @xref{Features}.
103 103
@@ -201,7 +201,7 @@ The returned value of this command is unpredictable.
201This function runs @code{byte-compile-file} on files specified on the 201This function runs @code{byte-compile-file} on files specified on the
202command line. This function must be used only in a batch execution of 202command line. This function must be used only in a batch execution of
203Emacs, as it kills Emacs on completion. An error in one file does not 203Emacs, as it kills Emacs on completion. An error in one file does not
204prevent processing of subsequent files. (The file which gets the error 204prevent processing of subsequent files. (The file that gets the error
205will not, of course, produce any compiled code.) 205will 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
241This form marks @var{body} to be evaluated at compile time @emph{only}. 241This form marks @var{body} to be evaluated at compile time and not when
242The result of evaluation by the compiler becomes a constant which 242the compiled program is loaded. The result of evaluation by the
243appears in the compiled program. When the program is interpreted, not 243compiler becomes a constant which appears in the compiled program. When
244compiled at all, @var{body} is evaluated normally. 244the program is interpreted, not compiled at all, @var{body} is evaluated
245normally.
245 246
246At top-level, this is analogous to the Common Lisp idiom 247At 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.
279The string containing the byte-code instructions. 280The string containing the byte-code instructions.
280 281
281@item constants 282@item constants
282The vector of constants referenced by the byte code. 283The vector of Lisp objects referenced by the byte code. These include
284symbols used as function names and variable names.
283 285
284@item stacksize 286@item stacksize
285The maximum stack size this function needs. 287The 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
320function yourself, because if they are inconsistent, Emacs may crash 322function yourself, because if they are inconsistent, Emacs may crash
321when you call the function. Always leave it to the byte-compiler to 323when you call the function. Always leave it to the byte compiler to
322create these objects; it makes the elements consistent (we hope). 324create 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.
338It pushes values onto a stack of its own, then pops them off to use them 340It pushes values onto a stack of its own, then pops them off to use them
339in calculations and push the result back on the stack. When a byte-code 341in calculations whose results are themselves pushed back on the stack.
340function returns, it pops a value off the stack and returns it as the 342When a byte-code function returns, it pops a value off the stack and
341value of the function. 343returns 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
344ordinary Lisp variables, by transferring values between variables and 346ordinary Lisp variables, by transferring values between variables and
345the stack. 347the 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
5409 goto-if-nil-else-pop 17 ; @r{Goto 17 if @code{n} > 0} 5429 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
56417 discard ; @r{Discard result of while loop} 56617 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
24or, optionally, as byte-compiled code. Each form in the file is called 24or as byte-compiled code. Each form in the file is called a
25a @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
26loadable file; any form in a file may equally well be typed directly 26loadable file; any form in a file may equally well be typed directly
27into a buffer and evaluated there. (Indeed, most code is tested this 27into a buffer and evaluated there. (Indeed, most code is tested this
28way.) Most often, the forms are function definitions and variable 28way.) 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
63loaded. If there is no file by that name, then @code{load} looks for a 63loaded. If there is no file by that name, then @code{load} looks for a
64file names @file{@var{filename}.el}. If that file exists, it is loaded. 64file named @file{@var{filename}.el}. If that file exists, it is loaded.
65Finally, if neither of those names is found, @code{load} looks for a 65Finally, if neither of those names is found, @code{load} looks for a
66file named @var{filename} with nothing appended, and loads it if it 66file named @var{filename} with nothing appended, and loads it if it
67exists. (The @code{load} function is not clever about looking at 67exists. (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
94Any unhandled errors while loading a file terminate loading. If the 94Any unhandled errors while loading a file terminate loading. If the
95load was done for the sake of @code{autoload}, certain kinds of 95load was done for the sake of @code{autoload}, any function definitions
96top-level forms, those which define functions, are undone. 96made during the loading are undone.
97 97
98@kindex file-error 98@kindex file-error
99If @code{load} can't find the file to load, then normally it signals the 99If @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
166the @file{/usr/local/lisplib} directory, 166the @file{/usr/local/lisplib} directory,
167which are then followed by the standard directories for Lisp code. 167which are then followed by the standard directories for Lisp code.
168 168
169The command line options @samp{-l} or @samp{-load} specify Lispa library 169The command line options @samp{-l} or @samp{-load} specify a Lisp
170to load. Since this file might be in the current directory, Emacs 18 170library to load as part of Emacs startup. Since this file might be in
171temporarily adds the current directory to the front of @code{load-path} 171the current directory, Emacs 18 temporarily adds the current directory
172so the file can be found there. Newer Emacs versions also find such 172to the front of @code{load-path} so the file can be found there. Newer
173files in the current directory, but without altering @code{load-path}. 173Emacs versions also find such files in the current directory, but
174without 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
202comments are the most convenient way to make a function autoload, but 203comments are the most convenient way to make a function autoload, but
203only for packages installed along with Emacs. 204only 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
206This function defines the function (or macro) named @var{symbol} so as 207This function defines the function (or macro) named @var{function} so as
207to load automatically from @var{filename}. The string @var{filename} 208to load automatically from @var{filename}. The string @var{filename}
208specifies the file to load to get the real definition of @var{function}. 209specifies 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
227loading the real definition. 228loading the real definition.
228 229
229@cindex function cell in autoload 230@cindex function cell in autoload
230If @var{symbol} already has a non-void function definition that is not 231If @var{function} already has a non-void function definition that is not
231an autoload object, @code{autoload} does nothing and returns @code{nil}. 232an autoload object, @code{autoload} does nothing and returns @code{nil}.
232If the function cell of @var{symbol} is void, or is already an autoload 233If the function cell of @var{function} is void, or is already an autoload
233object, then it is defined as an autoload object like this: 234object, 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
280function definition, it is copied verbatim. You can also use a magic 281function definition, it is copied verbatim. You can also use a magic
281comment to execute a form at build time executing it when the file 282comment to execute a form at build time @emph{without} executing it when
282itself is loaded. To do this, write the form @dfn{on the same line} as 283the file itself is loaded. To do this, write the form @dfn{on the same
283the magic comment. Since it is in a comment, it does nothing when you 284line} as the magic comment. Since it is in a comment, it does nothing
284load the source file; but @code{update-file-autoloads} copies it to 285when you load the source file; but @code{update-file-autoloads} copies
285@file{loaddefs.el}, where it is executed while building Emacs. 286it 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
288autoloading with a magic comment: 289autoloading with a magic comment:
@@ -367,7 +368,9 @@ has been loaded before:
367@noindent 368@noindent
368If the library uses @code{provide} to provide a named feature, you can 369If the library uses @code{provide} to provide a named feature, you can
369use @code{featurep} to test whether the library has been loaded. 370use @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.
391feature name as argument. @code{require} looks in the global variable 394feature 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
393already. If not, it loads the feature from the appropriate file. This 396already. If not, it loads the feature from the appropriate file. This
394file should call @code{provide} at the top-level to add the feature to 397file 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
427done. 430done.
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
431when you byte-compile that file (@pxref{Byte Compilation}) as well as 434when you byte-compile that file (@pxref{Byte Compilation}) as well as
432when you load it. This is in case the required package contains macros 435when you load it. This is in case the required package contains macros
433that the byte compiler must know about. 436that 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
453The compiler ignores the @code{provide}, then processes the
454@code{require} by loading the file in question. Loading the file does
455execute the @code{provide} call, so the subsequent @code{require} call
456does nothing while loading.
457
449@defun provide feature 458@defun provide feature
450This function announces that @var{feature} is now loaded, or being 459This function announces that @var{feature} is now loaded, or being
451loaded, into the current Emacs session. This means that the facilities 460loaded, 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
510This command unloads the library that provided feature @var{feature}. 519This command unloads the library that provided feature @var{feature}.
511It undefines all functions and variables defined with @code{defvar}, 520It undefines all functions, macros, and variables defined in that
512@code{defmacro}, @code{defconst}, @code{defsubst} and @code{defalias} by 521library with @code{defconst}, @code{defvar}, @code{defun},
513that library. It then restores any autoloads associated with those 522@code{defmacro}, @code{defsubst} and @code{defalias}. It then restores
514symbols. 523any 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
531Symbols, which were defined as functions or variables. 540Symbols that were defined by this library.
532@item 541@item
533Lists of the form @code{(require . @var{feature})} indicating 542Lists of the form @code{(require . @var{feature})} indicating
534features that were required. 543features that were required.