[plt-scheme] How to get the source of procedure?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Tue May 16 18:21:22 EDT 2006

On 5/16/06, Nicholas Chubrich <chubrich at cs.brandeis.edu> wrote:
> Would it be accurate to say that this only works when the modules are
> explicitly imported?  For instance, I have a little piece of code that
> relies on the fact that the MrEd functionality is already included in the
> Graphical language; right clicking on for instance the "send" procedure
> doesn't offer to jump to a definition.  I seem to have to have an explicit
> importation of class.ss to do that.  Is there any way to get this
> functionality for any built-in function in any context?

Short answer: no.

Long answer: "send" and the class library are not actually built in.
They are written in Scheme like any user module, as are many of the
tools you use in Scheme on a regular basis.  Anyone else could write
another module with a "send" operation, and it could even be a
different kind of class system (actually, I have done exactly this).
If you write "send" in your own module, and don't import anything,
DrScheme doesn't know if you mean class.ss's "send", or my "send", or
another "send" you were thinking of.  That's why you have to
explicitly import any function you want to use.

Now, if you don't want to have to import the libraries you commonly
import, you can always write a custom language level that imports them
at the top-level, so they would behave as if "built-in".  That won't
solve the problem in general, but it will work for things like "send"
that you use frequently.

Carl Eastlund
"Cynical, but technically correct."

Posted on the users mailing list.