[plt-scheme] Re: procedure instrospection

From: Jose A. Ortega Ruiz (jao at gnu.org)
Date: Sun Apr 26 14:42:04 EDT 2009

Ryan Culpepper <ryanc at ccs.neu.edu> writes:


[...]

> For the most part, no. That information isn't attached to procedures.
>
> The easiest question is "What file is a name defined in?"
>
>   ;; definition-source : identifier -> (U symbol path)
>   ;; Returns a symbol or path for the module that contains
>   ;; the definition for a given name.
>   (define (definition-source id)
>     (let ([binding (identifier-binding id)])
>       (and (list? binding)
>            (resolved-module-path-name
>             (module-path-index-resolve (car binding))))))

Thank you, that works for me. I have what must be a silly question,
though. From emacs, what i have is a symbol, not an identifier, and i'd
like to call definition-source as, e.g., (definition-source 'map) (i.e.,
using a symbol naming the identifier as argument)... but i cannot figure
how to go from symbol to identifier in a way that identifier-binding
understands. I'm clearly not understanding the relationship between
symbols and identifier, so i'd appreciate any help or pointer to
documentation.

Thanks!
jao





Posted on the users mailing list.