[Top][All Lists]

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

Re: subverting use-modules restriction + module system RFD

From: Marius Vollmer
Subject: Re: subverting use-modules restriction + module system RFD
Date: 13 Sep 2001 13:56:53 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

thi <address@hidden> writes:

> in guile 1.5.x and later, `use-modules' is permitted only at top-level.
> suppose you're writing some kind of shell that only loads modules on
> demand, in which case a non top-level (e.g., conditional, programmatic)
> "use-modules" is desirable.  you can try this:
> (define (runtime-use-modules name)
>   (process-use-modules
>     (list (list name))))

I prefer a more explicit style that doesn't rely on the `current
module'.  The current module concept is mainly useful while loading
and executing top-level forms, but it is not really meaningful for
code that is executed not a top-level (i.e. closures).

    (define (runtime-use-module module name)
      (module-use! module (resolve-interface name)))

As an aside, and not really related to your main point:

> simple example:
> (case (string->symbol (cadr (command-line)))
>   ((state-summary)
>    (runtime-use-modules '(ttn rcsutils))
>    (for-each display-rcs-state-summary (cddr (command-line))))
>   (else
>    (error "command not found")))

This ought to work with `use-modules', actually, when the whole
expression is on top-level.  Currently, the body forms of a `case',
`cond', `if', and `begin' are on top-level when the whole form is.
This is probably only an implementation artifact however, and might
vanish.  That is, `begin' subforms will always be on top-level when
the begin is, but for the rest I'm not sure.

Anyway, your reasoning is of course correct, and a programmatic
interface to the module system is needed.

reply via email to

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