[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
straw proposal: heuristic info from procedures
Will Clinger proposed:
> (procedure-arity _proc_)
> Returns information about the arity of _proc_. This information
> can take several forms:
> an exact non-negative integer k: _proc_ requires exactly k
> (k): _proc_ requires at least k arguments.
> (k1 k2): _proc_ requires at least k1 but no more than k2 arguments.
> #F: no information on the arity of _proc_ is available.
I would like to see any procedure-arity proposal take into account the
possibility of extending Scheme with case-lambda (a la Dybvig/Hieb).
In this case, a procedure has multiple "traditional" arities -- your
second case does not cover this one, since there could be holes.
In MzScheme, the arity procedure (whose documentation is available at
followed by the "Arity" entry) returns
1. a number,
2. the structure arity-at-least, whose field value gives the actual
minimum number, or
3. a list of elements of type 1. and 2. (representing case-lambda).
> (procedure-source-file _proc_)
> Returns the name of the file that contains the source code for
> _proc_, as a string, or returns #F if this information is not
> (procedure-source-position _proc_)
> Returns an exact integer that specifies the number of characters
> that precede the opening parenthesis of the source code for _proc_
> within the source file returned by PROCEDURE-SOURCE-FILE, or
> returns #F if this information is not available.
> (procedure-code _proc_)
> Returns the source code for _proc_ as a lambda expression, in the
> traditional representation as a list, or returns #F if no source
> code is available for _proc_.
These three could be merged if instead there were a single procedure
that returned the location-annotated source of the procedure. At
least, these three could be defined as primitives on top of that.
Also, I really don't like this dependence on "files", but so be it.