In addition to the information that is strictly necessary to run, procedures may have other associated information. For example, the name of a procedure is information not for the procedure, but about the procedure. This meta-information can be accessed via the procedure properties interface.
Return #t
if obj is a procedure.
Return #t
if obj is a procedure that can be called with
zero arguments. See Compiled Procedures, to get more information
on what arguments a procedure will accept.
Procedure properties are general properties associated with procedures. These can be the name of a procedure or other relevant information, such as debug hints.
The most general way to associate a property of a procedure is programmatically:
Return the property of proc with name key, or #f
if
not found.
Set proc’s property named key to value.
However, there is a more efficient interface that allows constant properties to be embedded into compiled binaries in a way that does not incur any overhead until someone asks for the property: initial non-tail elements of the body of a lambda expression that are literal vectors of pairs are interpreted as declaring procedure properties. This is easiest to see with an example:
(define proc (lambda args #((a . "hey") (b . "ho")) ;; procedure properties! 42)) (procedure-property proc 'a) ; ⇒ "hey" (procedure-property proc 'b) ; ⇒ "ho"
There is a shorthand for declaring the documentation
property,
which is a literal string instead of a literal vector:
(define proc (lambda args "This is a docstring." 42)) (procedure-property proc 'documentation) ;; ⇒ "This is a docstring."
Calling procedure-property
with a key of documentation
is exactly the same as calling procedure-documentation
.
Similarly, procedure-name
is the same as the name
procedure property, and procedure-source
is for the
source
property.
Return the value of the name
, source
, or
documentation
property for proc, or #f
if no
property is set.
One can also work on the entire set of procedure properties.