[plt-scheme] recover a procedure body?

From: Ron Stanonik (stanonik at Cogsci.ucsd.edu)
Date: Mon Oct 14 14:37:35 EDT 2002

On Wed, 25 Sep 2002, Matthew Flatt wrote:
> There's no built-in support for recovering the procedure body or
> arguments.
> 
> If you have control over the context where the procedure is created,
> you can redefine `lambda' to keep that information.
> 
>  ; This example uses v202.2 procedure structures
>  (module new-lambda mzscheme
> 
>   (provide (rename new-lambda lambda)
>            procedure-body
>            procedure-args)
>   
>   (define-values (struct:ap make-annotated-proc annotated-proc? ap-ref ap-set!) 
>     (make-struct-type 'anotated-proc #f 3 0 #f null #f 0))
>   
>   (define procedure-args (make-struct-field-accessor ap-ref 1))
>   (define procedure-body (make-struct-field-accessor ap-ref 2))
>   
>   (define-syntax new-lambda
>     (syntax-rules ()
>       [(_ args . body)
>        (make-annotated-proc (lambda args . body) 'args 'body)])))
> 
> If you don't have control over that context, then there are lots of
> problems (e.g., the procedure might be implemented in an extension).

If I use this in mzscheme or mred, then I get an "out of memory error"
when I define a case-lamba.  I don't get an error in drscheme or if the
case-lambda is defined in a class.  What is drscheme doing differently?
Can I do that in mred?  (We're trying to run mred from within emacs, which
is why we don't use drscheme.)

Thanks,

Ron
stanonik at cogsci.ucsd.edu



Posted on the users mailing list.