guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a list of procedures in a file.


From: Richard Shann
Subject: Re: Creating a list of procedures in a file.
Date: Fri, 20 Nov 2009 10:43:41 +0000

Works like a dream - thank you!
Richard


On Thu, 2009-11-19 at 22:41 +0000, Neil Jerram wrote:
> Richard Shann <address@hidden> writes:
> 
> > Thanks for this: the only problem might be that it is the top-level
> > definitions in Denemo's initialization script that I want to list. I
> > haven't created a module for it (I wouldn't know how! But as it is very
> > much an end user, I suppose there is no need).
> > I tried '(current-module) where you have '(the denemo module) with a
> > (no code for module (current-module) error message.
> > Any further thoughts?
> > Thanks again,
> 
> (current-module) should replace the whole (resolve-interface ...) form,
> i.e.:
> 
>    (module-for-each (lambda (name var)
>                       (format #t "variable `~A', value `~s'~%" name
>                               (variable-ref var)))
>                     (current-module))
> 
> Within Denemo, you could arrange things such that the initialization
> script was loaded in the context of a specially created module; then an
> approach like the above should be fine.
> 
> Alternatively, assuming that it is safe to do so - i.e. that there are
> no possible side-effects from reading - you could just read and process
> the script.  Something like:
> 
> (with-input-from-file FILENAME
>   (lambda ()
>     (let loop ((x (read)) (defs '()))
>       (if (eof-object? x)
>           defs
>           (loop (read) (if (and (list? x)
>                                 (>= (length x) 3)
>                                 (eq? (car x) 'define)
>                                 (pair? (cadr x)))
>                            (cons (caadr x) defs)
>                            defs))))))
> 
> (completely untested, of course!)
> 
>        Neil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]