[plt-scheme] Displaying the function body
On Thu, 9 Dec 2004 11:49:48 -0800, Dmitriy.Zavin at infineon.com
<Dmitriy.Zavin at infineon.com> wrote:
> I was wondering how one would go about displaying the function body of a
> function that is currently defined? (something equivalent to Tcl's
> "info body <func>"
I had a similar need, but only for lambdas I created.
Mathew Flatt responded with
(module new-lambda mzscheme
(provide new-lambda ;(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)]))
)
Hope it helps.
Ron