X-Git-Url: http://git.hcoop.net/bpt/guile.git/blobdiff_plain/747bd5347d8b36c41809a16cb3f17b23e9afa9bf..fb50a753e125f77093826963fd786b9592f7e08d:/doc/ref/api-procedures.texi diff --git a/doc/ref/api-procedures.texi b/doc/ref/api-procedures.texi index bef3386e8..02bf6822a 100644 --- a/doc/ref/api-procedures.texi +++ b/doc/ref/api-procedures.texi @@ -157,51 +157,34 @@ appropriate module first, though: @deffn {Scheme Procedure} program? obj @deffnx {C Function} scm_program_p (obj) -Returns @code{#t} iff @var{obj} is a compiled procedure. +Returns @code{#t} if @var{obj} is a compiled procedure, or @code{#f} +otherwise. @end deffn -@deffn {Scheme Procedure} program-objcode program -@deffnx {C Function} scm_program_objcode (program) -Returns the object code associated with this program. @xref{Bytecode -and Objcode}, for more information. +@deffn {Scheme Procedure} program-code program +@deffnx {C Function} scm_program_code (program) +Returns the address of the program's entry, as an integer. This address +is mostly useful to procedures in @code{(system vm debug)}. @end deffn -@deffn {Scheme Procedure} program-objects program -@deffnx {C Function} scm_program_objects (program) -Returns the ``object table'' associated with this program, as a -vector. @xref{VM Programs}, for more information. +@deffn {Scheme Procedure} program-num-free-variable program +@deffnx {C Function} scm_program_num_free_variables (program) +Return the number of free variables captured by this program. @end deffn -@deffn {Scheme Procedure} program-module program -@deffnx {C Function} scm_program_module (program) -Returns the module that was current when this program was created. Can -return @code{#f} if the compiler could determine that this information -was unnecessary. -@end deffn - -@deffn {Scheme Procedure} program-free-variables program -@deffnx {C Function} scm_program_free_variables (program) -Returns the set of free variables that this program captures in its -closure, as a vector. If a closure is code with data, you can get the -code from @code{program-objcode}, and the data via -@code{program-free-variables}. - -Some of the values captured are actually in variable ``boxes''. -@xref{Variables and the VM}, for more information. +@deffn {Scheme Procedure} program-free-variable-ref program n +@deffnx {C Function} scm_program_free_variable-ref (program, n) +@deffnx {Scheme Procedure} program-free-variable-set! program n val +@deffnx {C Function} scm_program_free_variable_set_x (program, n, val) +Accessors for a program's free variables. Some of the values captured +are actually in variable ``boxes''. @xref{Variables and the VM}, for +more information. Users must not modify the returned value unless they think they're really clever. @end deffn -@deffn {Scheme Procedure} program-meta program -@deffnx {C Function} scm_program_meta (program) -Return the metadata thunk of @var{program}, or @code{#f} if it has no -metadata. - -When called, a metadata thunk returns a list of the following form: -@code{(@var{bindings} @var{sources} @var{arities} . @var{properties})}. The format -of each of these elements is discussed below. -@end deffn +@c FIXME @deffn {Scheme Procedure} program-bindings program @deffnx {Scheme Procedure} make-binding name boxed? index start end @@ -296,7 +279,7 @@ list, or @code{#f} if this information is not available. For example: @example -(program-lambda-alist +(program-lambda-list (lambda* (a b #:optional c #:key (d 1) #:rest e) #t)) @result{} @end example @@ -333,7 +316,11 @@ cheaply, without allocating a rest list. @code{lambda*} is like @code{lambda}, except with some extensions to allow optional and keyword arguments. -@deffn {library syntax} lambda* ([var@dots{}] @* [#:optional vardef@dots{}] @* [#:key vardef@dots{} [#:allow-other-keys]] @* [#:rest var | . var]) @* body +@deffn {library syntax} lambda* ([var@dots{}] @* @ + [#:optional vardef@dots{}] @* @ + [#:key vardef@dots{} [#:allow-other-keys]] @* @ + [#:rest var | . var]) @* @ + body1 body2 @dots{} @sp 1 Create a procedure which takes optional and/or keyword arguments specified with @code{#:optional} and @code{#:key}. For example, @@ -570,7 +557,8 @@ with @code{lambda} (@pxref{Lambda}). @example @group - --> (case-lambda ) + --> (case-lambda *) + --> (case-lambda *) --> ( *) @@ -585,6 +573,7 @@ Rest lists can be useful with @code{case-lambda}: @lisp (define plus (case-lambda + "Return the sum of all arguments." (() 0) ((a) a) ((a b) (+ a b)) @@ -712,6 +701,11 @@ compatible arity. Return X. @end deffn +@deffn {Scheme Procedure} and=> value proc +When @var{value} is @code{#f}, return @code{#f}. Otherwise, return +@code{(@var{proc} @var{value})}. +@end deffn + @node Procedure Properties @subsection Procedure Properties and Meta-information