[plt-scheme] procedure instrospection

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Apr 18 03:39:45 EDT 2009

On Apr 18, Jose A. Ortega Ruiz wrote:
> Eli Barzilay <eli at barzilay.org> writes:
> > On Apr 18, Jose A. Ortega Ruiz wrote:
> >> specially for the case of formals names. i'm thinking of
> >> something simple, and not necessarily 100% accurate--a hash table
> >> maintained separately, say, recording metadata computed during
> >> evaluation.
> >
> > The real way to do that is if there was a way at the core to make
> > procedures somehow remember their arguments.  It's not difficult
> > to add a `lambda' form that does that, but it won't help with
> > existing code.
> given that it doesn't seem difficult to accomplish, any chance that
> it could be added to a future relase? for instance, it'd be very
> nice to have a 'status bar' in DrScheme showing this information
> (i'll be showing it in an emacs mode i'm working on).

I'm not sure...  It would need to be some "proper" solution for it to
be useful enough to be added.  For example, such an emacs facility
would be very helpful (and in drscheme too, of course), but it should
also deal with macros.  And macros should not be dismissed into "hard
cases that are left with no solution for now" -- they are much more
common than you'd think...  For example, contracted functions are
actually macros.

> right. but my guess is that those case are not that common, and for
> them i can fall back to displaying an argument list derived from
> arity information (is that still available for them?) with dummy arg
> names.

Yes, the arity list is still available.  In fact the mechanism that
keeps track of the arity is the best place to add a facility like you
want, but it's not hackable since it's in the core...   But it does
point at yet another problem -- what are the argument names you'd
expect for this:

  (define foo
    (case-lambda [(x)   "stuff"]
                 [(a b) "other stuff"]))


          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.