(make-procedure length) => procedure
(procedure-length procedure) => fixnum
(procedure-ref procedure offset) => object
(procedure-set! procedure offset object)
=> unspecified
These procedures operate on the representations of procedures and allow user programs to construct, inspect, and alter procedures.
(procedure-copy procedure) => procedure
Returns a shallow copy of the procedure.
The rest of this section describes some procedures that extract heuristic information from procedures, for debugging purposes. The text is copied from a straw proposal authored by Will Clinger and sent to rrr-authors on 09 May 1996. The text has been edited lightly. See the end for notes about the Larceny implementation.
The procedures that extract heuristic information from procedures are permitted to return any result whatsoever. If the type of a result is not among those listed below, then the result represents an implementation-dependent extension to this interface, which may safely be interpreted as though no information were available from the procedure. Otherwise the result is to be interpreted as described below.
Returns information about the arity of proc. If the result is #F, then no information is available. If the result is an exact non-negative integer k, then proc requires exactly k arguments. If the result is an inexact non-negative integer n, then proc requires n or more arguments. If the result is a pair, then it is a list of non-negative integers, each of which indicates a number of arguments that will be accepted by proc; the list is not necessarily exhaustive.
Returns general information about proc. If the result is #F, then no information is available. If the result is a string, then it is to be interpreted as a "documentation string" (see Common Lisp).
Returns information about the name of proc. If the result is #F, then no information is available. If the result is a symbol or string, then it represents a name. If the result is a pair, then it is a list of symbols and/or strings representing a path of names; the first element represents an outer name and the last element represents an inner name.
Returns information about the name of a file that contains the source code for proc. If the result is #F, then no information is available. If the result is a string, then the string is the name of a file.
Returns information about the position of the source code for proc whithin the source file specified by procedure-source-file. If the result is #F, then no information is available. If the result is an exact integer k, then k characters precede the opening parenthesis of the source code for proc within that source file.
Returns information about the source code for proc. If the result is #F, then no information is available. If the result is a pair, then it is a lambda expression in the traditional representation of a list.
Returns information about the environment of proc. If the result is #F, then no information is available. In any case the result may be passed to any of the environment inquiry functions.
Notes on the Larceny implementation
Twobit does not yet produce data for all of these functions, so some of them always return #f.