[plt-scheme] introspection

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Oct 23 08:22:54 EDT 2007

On 10/23/07, Rohan Nicholls <rohan.nicholls at googlemail.com> wrote:
> I have been trying to figure out how I can find out what the
> properties of an element  are within a live environment.
> e.g. I am looking at a function - what are its calling protocol is
> etc.
> Also useful would be a reference to where the source can be found, but
> it is likely that is not stored in the running image.  I am thinking
> of something like find-function in emacs.

Some things, like procedure arity, are stored at runtime and available
by specific procedures, but many are not.  The "calling protocol" of a
function may (or may not) be stored as a contract, but those are not
inspectable in any meaningful way at runtime; Help Desk is your best
bet for documentation.

If you want to get at the source of a function, first try the dropdown
at the top-left of your emacs window, the one labeled (define ...).
It opens up a list of defined names in your file, and jumps to the one
you select.  For functions outside your current file, try using the
Check Syntax button.  It lets you right-click on identifiers and
select "Jump to Definition", opening other files if needed.  It's not
quite a runtime feature, but it does help.

> I have searched in the manuals and the help desk, but cannot find
> anything, although maybe I am looking for the wrong things.
>
> On a related note, I know that there are no docstrings in plt scheme
> such as you find in lisp and python, but in htdp and other plt related
> material there seems to be a a convention that goes something like
> this:
>
> ;; name-of-func : calling protocol -> return value
> ;; description of functionality etc.
> (define name-of-func ....
>
> Is this information actually processed in some way making it
> accessible to querying from the image? I guess I can hack something
> together if the find-function equivalent exists.

These are just comments.  We do not currently associate them with
identifiers in any programmatic way.  The new documentation tool
Scribble automatically associates documentation with functions; it
doesn't look quite like this, but once it's in widespread use it'll be
a step closer to what you're looking for.

I hope this helps!

> Thanks in advance, and really enjoying all the new (for me) features
> you have added to the language.
>
> Rohan

-- 
Carl Eastlund


Posted on the users mailing list.