Procedures

Operations on procedures

(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 procedure-copy

(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.

(procedure-arity proc)

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.

(procedure-documentation-string proc)

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).

(procedure-name proc)

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.

(procedure-source-file proc)

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.

(procedure-source-position proc)

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.

(procedure-expression proc)

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.

(procedure-environment proc)

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.


$Id: procedures.html,v 1.5 2000/09/12 02:46:46 lth Exp $
larceny@ccs.neu.edu