0

I want to see all user-made definitions in a Scheme REPL, both loaded from files and entered at the REPL. Is there any way to "dump all definitions"?

E.g. if there is:

    (define (plusone x) (+ 1 x))
    (define (plustwo x) (+ 2 x))
    (define (plusthree x) (+ 3 x))

then I want to see all of these definitions, but only those defined by the "user" - something like ",showmealldefs" or thelike. Can this be done, and if there is no general way, can this be done in Gambit-C?

(I tried (apropos ""), and this is not what I mean.)

1

You're looking to manipulate the environment. Support of first class environments is not common in the various Schemes. MIT Scheme has support (I believe the function is gst), but I don't believe that Gambit-C does. Some discussion about first class environments are here.

If you were to write your own metacircular Scheme (Scheme written in Scheme) you'd write an eval function and an apply function which would have some sort of environment passed along with them. Since the environment would probably be an association list of name/function, you'd be able to manipulate them as you wished. However, I don't think you're going to find what you're looking for in most full-fledged Schemes because of performance/implementation reasons.

  • I kindly thank you for your answer. - I actually just want to "see" the environment, "as it currently is", but if it is impossible... that's life, I'm a relative beginner. – Aeneas May 13 '13 at 9:15
  • I believe that because of things getting compiled and various other reasons, there's no way of just printing it out in most Schemes. I'm fairly certain that if there is, there's no standardized method. – Greg May 13 '13 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.