[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get a list of top-level definitions?
From: |
Rob Browning |
Subject: |
Re: How to get a list of top-level definitions? |
Date: |
12 Jun 2001 12:13:12 -0500 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Sam Tregar <address@hidden> writes:
> Ok. Here's what I need - given a block of Guile code I need to
> evaluate it (eval_str()) and then get a list of all the top-level
> definitions it just created. My plan was to get a list of existing
> top-level definitions before the eval and then get the list
> afterwards and do a diff to get the new ones. At this point I'm not
> too concerned with supporting modules outside of making (use-module)
> work, which should be automatic.
Well, one simplistic approach, might be to define your own var
"my-project-newdefs". Then, redefine define like this:
(let ((primitive-define define))
(define-macro (define name . args)
(set! my-project-newdefs (cons name my-project-newdefs))
`(,primitive-define ,name ,@args))
Then all you have to do when you want to eval some string and capture
the definitions is
1) (set! my-project-newdefs '())
2) gh_eval_str(str);
3) check my-project-newdefs
This might or might not be a sufficient depending on your needs, and I
haven't tested it, so I'm not sure it'll really work.
> Is the top-level actually some kind of default module?
Yes. Usually guile-user.
--
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930