Node:Procedure Properties,
Next:Procedures with Setters,
Previous:Optional Arguments,
Up:Procedures and Macros
23.3 Procedure Properties and Meta-information
Procedures always have attached the environment in which they were
created and information about how to apply them to actual arguments. In
addition to that, properties and meta-information can be stored with
procedures. The procedures in this section can be used to test whether
a given procedure satisfies a condition; and to access and set a
procedure's property.
The first group of procedures are predicates to test whether a Scheme
object is a procedure, or a special procedure, respectively.
procedure?
is the most general predicates, it returns #t
for any kind of procedure. closure?
does not return #t
for primitive procedures, and thunk?
only returns #t
for
procedures which do not accept any arguments.
procedure? obj
|
Scheme Procedure |
scm_procedure_p (obj)
|
C Function |
Return #t if obj is a procedure.
|
closure? obj
|
Scheme Procedure |
scm_closure_p (obj)
|
C Function |
Return #t if obj is a closure.
|
thunk? obj
|
Scheme Procedure |
scm_thunk_p (obj)
|
C Function |
Return #t if obj is a thunk.
|
Procedure properties are general properties to be attached to
procedures. These can be the name of a procedure or other relevant
information, such as debug hints.
procedure-name proc
|
Scheme Procedure |
scm_procedure_name (proc)
|
C Function |
Return the name of the procedure proc
|
procedure-source proc
|
Scheme Procedure |
scm_procedure_source (proc)
|
C Function |
Return the source of the procedure proc.
|
procedure-environment proc
|
Scheme Procedure |
scm_procedure_environment (proc)
|
C Function |
Return the environment of the procedure proc.
|
procedure-properties proc
|
Scheme Procedure |
scm_procedure_properties (proc)
|
C Function |
Return obj's property list.
|
procedure-property obj key
|
Scheme Procedure |
scm_procedure_property (obj, key)
|
C Function |
Return the property of obj with name key.
|
set-procedure-properties! proc alist
|
Scheme Procedure |
scm_set_procedure_properties_x (proc, alist)
|
C Function |
Set obj's property list to alist.
|
set-procedure-property! obj key value
|
Scheme Procedure |
scm_set_procedure_property_x (obj, key, value)
|
C Function |
In obj's property list, set the property named key to
value.
|
Documentation for a procedure can be accessed with the procedure
procedure-documentation
.
procedure-documentation proc
|
Scheme Procedure |
scm_procedure_documentation (proc)
|
C Function |
Return the documentation string associated with proc . By
convention, if a procedure contains more than one expression and the
first expression is a string constant, that string is assumed to contain
documentation for that procedure.
|
Source properties are properties which are related to the source code of
a procedure, such as the line and column numbers, the file name etc.
set-source-properties! obj plist
|
Scheme Procedure |
scm_set_source_properties_x (obj, plist)
|
C Function |
Install the association list plist as the source property
list for obj.
|
set-source-property! obj key datum
|
Scheme Procedure |
scm_set_source_property_x (obj, key, datum)
|
C Function |
Set the source property of object obj, which is specified by
key to datum. Normally, the key will be a symbol.
|
source-properties obj
|
Scheme Procedure |
scm_source_properties (obj)
|
C Function |
Return the source property association list of obj.
|
source-property obj key
|
Scheme Procedure |
scm_source_property (obj, key)
|
C Function |
Return the source property specified by key from
obj's source property list.
|