[Top][All Lists]

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

Re: Creating a list of procedures in a file.

From: Neil Jerram
Subject: Re: Creating a list of procedures in a file.
Date: Thu, 19 Nov 2009 22:41:16 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

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,

   (module-for-each (lambda (name var)
                      (format #t "variable `~A', value `~s'~%" name
                              (variable-ref var)))

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)
          (loop (read) (if (and (list? x)
                                (>= (length x) 3)
                                (eq? (car x) 'define)
                                (pair? (cadr x)))
                           (cons (caadr x) defs)

(completely untested, of course!)


reply via email to

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