comparison man/internals/internals.texi @ 4962:e813cf16c015

merge
author Ben Wing <ben@xemacs.org>
date Mon, 01 Feb 2010 05:29:05 -0600
parents 304aebb79cd3 755ae5b97edb
children cbe181529c34
comparison
equal deleted inserted replaced
4961:b90f8cf474e0 4962:e813cf16c015
449 449
450 Evaluation; Stack Frames; Bindings 450 Evaluation; Stack Frames; Bindings
451 451
452 * Evaluation:: 452 * Evaluation::
453 * Dynamic Binding; The specbinding Stack; Unwind-Protects:: 453 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
454 * Simple Special Forms:: 454 * Simple Special Operators::
455 * Catch and Throw:: 455 * Catch and Throw::
456 * Error Trapping:: 456 * Error Trapping::
457 457
458 Symbols and Variables 458 Symbols and Variables
459 459
3516 @end example 3516 @end example
3517 3517
3518 This module contains all of the functions to handle the flow of control. 3518 This module contains all of the functions to handle the flow of control.
3519 This includes the mechanisms of defining functions, calling functions, 3519 This includes the mechanisms of defining functions, calling functions,
3520 traversing stack frames, and binding variables; the control primitives 3520 traversing stack frames, and binding variables; the control primitives
3521 and other special forms such as @code{while}, @code{if}, @code{eval}, 3521 and other special operators such as @code{while}, @code{if}, @code{eval},
3522 @code{let}, @code{and}, @code{or}, @code{progn}, etc.; handling of 3522 @code{let}, @code{and}, @code{or}, @code{progn}, etc.; handling of
3523 non-local exits, unwind-protects, and exception handlers; entering the 3523 non-local exits, unwind-protects, and exception handlers; entering the
3524 debugger; methods for the subr Lisp object type; etc. It does 3524 debugger; methods for the subr Lisp object type; etc. It does
3525 @emph{not} include the @code{read} function, the @code{print} function, 3525 @emph{not} include the @code{read} function, the @code{print} function,
3526 or the handling of symbols and obarrays. 3526 or the handling of symbols and obarrays.
5321 Lisp primitives are Lisp functions implemented in C. The details of 5321 Lisp primitives are Lisp functions implemented in C. The details of
5322 interfacing the C function so that Lisp can call it are handled by a few 5322 interfacing the C function so that Lisp can call it are handled by a few
5323 C macros. The only way to really understand how to write new C code is 5323 C macros. The only way to really understand how to write new C code is
5324 to read the source, but we can explain some things here. 5324 to read the source, but we can explain some things here.
5325 5325
5326 An example of a special form is the definition of @code{prog1}, from 5326 An example of a special operator is the definition of @code{prog1}, from
5327 @file{eval.c}. (An ordinary function would have the same general 5327 @file{eval.c}. (An ordinary function would have the same general
5328 appearance.) 5328 appearance.)
5329 5329
5330 @cindex garbage collection protection 5330 @cindex garbage collection protection
5331 @smallexample 5331 @smallexample
5402 function @code{prog1} allows a minimum of one argument. 5402 function @code{prog1} allows a minimum of one argument.
5403 5403
5404 @item max_args 5404 @item max_args
5405 This is the maximum number of arguments that the function accepts, if 5405 This is the maximum number of arguments that the function accepts, if
5406 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED}, 5406 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED},
5407 indicating a special form that receives unevaluated arguments, or 5407 indicating a special operator that receives unevaluated arguments, or
5408 @code{MANY}, indicating an unlimited number of evaluated arguments (the 5408 @code{MANY}, indicating an unlimited number of evaluated arguments (the
5409 C equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} 5409 C equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY}
5410 are macros. If @var{max_args} is a number, it may not be less than 5410 are macros. If @var{max_args} is a number, it may not be less than
5411 @var{min_args} and it may not be greater than 8. (If you need to add a 5411 @var{min_args} and it may not be greater than 8. (If you need to add a
5412 function with more than 8 arguments, use the @code{MANY} form. Resist 5412 function with more than 8 arguments, use the @code{MANY} form. Resist
5455 reserved words (like @code{default}) or global symbols (like 5455 reserved words (like @code{default}) or global symbols (like
5456 @code{dirname}) to be used as argument names without compiler warnings 5456 @code{dirname}) to be used as argument names without compiler warnings
5457 or errors. 5457 or errors.
5458 5458
5459 A Lisp function with @w{@var{max_args} = @code{UNEVALLED}} is a 5459 A Lisp function with @w{@var{max_args} = @code{UNEVALLED}} is a
5460 @w{@dfn{special form}}; its arguments are not evaluated. Instead it 5460 @w{@dfn{special operator}}; its arguments are not evaluated. Instead it
5461 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the 5461 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the
5462 unevaluated arguments, conventionally named @code{(args)}. 5462 unevaluated arguments, conventionally named @code{(args)}.
5463 5463
5464 When a Lisp function has no upper limit on the number of arguments, 5464 When a Lisp function has no upper limit on the number of arguments,
5465 specify @w{@var{max_args} = @code{MANY}}. In this case its implementation in 5465 specify @w{@var{max_args} = @code{MANY}}. In this case its implementation in
8952 @cindex bindings, evaluation; stack frames; 8952 @cindex bindings, evaluation; stack frames;
8953 8953
8954 @menu 8954 @menu
8955 * Evaluation:: 8955 * Evaluation::
8956 * Dynamic Binding; The specbinding Stack; Unwind-Protects:: 8956 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
8957 * Simple Special Forms:: 8957 * Simple Special Operators::
8958 * Catch and Throw:: 8958 * Catch and Throw::
8959 * Error Trapping:: 8959 * Error Trapping::
8960 @end menu 8960 @end menu
8961 8961
8962 @node Evaluation, Dynamic Binding; The specbinding Stack; Unwind-Protects, Evaluation; Stack Frames; Bindings, Evaluation; Stack Frames; Bindings 8962 @node Evaluation, Dynamic Binding; The specbinding Stack; Unwind-Protects, Evaluation; Stack Frames; Bindings, Evaluation; Stack Frames; Bindings
9088 @code{call3()} call a function, passing it the argument(s) given (the 9088 @code{call3()} call a function, passing it the argument(s) given (the
9089 arguments are given as separate C arguments rather than being passed as 9089 arguments are given as separate C arguments rather than being passed as
9090 an array). @code{apply1()} uses @code{Fapply()} while the others use 9090 an array). @code{apply1()} uses @code{Fapply()} while the others use
9091 @code{Ffuncall()} to do the real work. 9091 @code{Ffuncall()} to do the real work.
9092 9092
9093 @node Dynamic Binding; The specbinding Stack; Unwind-Protects, Simple Special Forms, Evaluation, Evaluation; Stack Frames; Bindings 9093 @node Dynamic Binding; The specbinding Stack; Unwind-Protects, Simple Special Operators, Evaluation, Evaluation; Stack Frames; Bindings
9094 @section Dynamic Binding; The specbinding Stack; Unwind-Protects 9094 @section Dynamic Binding; The specbinding Stack; Unwind-Protects
9095 @cindex dynamic binding; the specbinding stack; unwind-protects 9095 @cindex dynamic binding; the specbinding stack; unwind-protects
9096 @cindex binding; the specbinding stack; unwind-protects, dynamic 9096 @cindex binding; the specbinding stack; unwind-protects, dynamic
9097 @cindex specbinding stack; unwind-protects, dynamic binding; the 9097 @cindex specbinding stack; unwind-protects, dynamic binding; the
9098 @cindex unwind-protects, dynamic binding; the specbinding stack; 9098 @cindex unwind-protects, dynamic binding; the specbinding stack;
9146 a local-variable binding (@code{func} is 0, @code{symbol} is not 9146 a local-variable binding (@code{func} is 0, @code{symbol} is not
9147 @code{nil}, and @code{old_value} holds the old value, which is stored as 9147 @code{nil}, and @code{old_value} holds the old value, which is stored as
9148 the symbol's value). 9148 the symbol's value).
9149 @end enumerate 9149 @end enumerate
9150 9150
9151 @node Simple Special Forms, Catch and Throw, Dynamic Binding; The specbinding Stack; Unwind-Protects, Evaluation; Stack Frames; Bindings 9151 @node Simple Special Operators, Catch and Throw, Dynamic Binding; The specbinding Stack; Unwind-Protects, Evaluation; Stack Frames; Bindings
9152 @section Simple Special Forms 9152 @section Simple Special Operators
9153 @cindex special forms, simple 9153 @cindex special operators, simple
9154 @cindex special forms
9154 9155
9155 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn}, 9156 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn},
9156 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function}, 9157 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function},
9157 @code{let*}, @code{let}, @code{while} 9158 @code{let*}, @code{let}, @code{while}
9158 9159
9164 Note that, with the exception of @code{Fprogn}, these functions are 9165 Note that, with the exception of @code{Fprogn}, these functions are
9165 typically called in real life only in interpreted code, since the byte 9166 typically called in real life only in interpreted code, since the byte
9166 compiler knows how to convert calls to these functions directly into 9167 compiler knows how to convert calls to these functions directly into
9167 byte code. 9168 byte code.
9168 9169
9169 @node Catch and Throw, Error Trapping, Simple Special Forms, Evaluation; Stack Frames; Bindings 9170 @node Catch and Throw, Error Trapping, Simple Special Operators, Evaluation; Stack Frames; Bindings
9170 @section Catch and Throw 9171 @section Catch and Throw
9171 @cindex catch and throw 9172 @cindex catch and throw
9172 @cindex throw, catch and 9173 @cindex throw, catch and
9173 9174
9174 @example 9175 @example