Hi Rob,

Rob Browning <r...@defaultvalue.org> writes:

> This doesn't work with 2.2.4:
>
>   (eval-when (expand load eval)
>     (let ((ignored #t))
>       (define-module (bar)
>         #:use-module (has-foo))
>       (format #t "foo: ~s\n" (foo))))
>
> producing:
>
>   ERROR: In procedure %resolve-variable:
>   Unbound variable: foo

'define-module' should only be used at top-level.  Ideally, we should
report a clearer error when it's used elsewhere.

> Is that expected?  I'm not sure if what I was attempting is reasonable,
> but the original motivation was wanting to create a syntax that can
> capture and restore some state around the invocation of define-module,
> e.g.:
>
>   (define-syntax def-mod
>     (lambda (x)
>       (syntax-case x ()
>         ((_ name)
>          #`(eval-when (expand load eval)
>              (let ((orig (current-language)))
>                (current-language 'scheme)
>                (define-module name
>                  #:use-module (has-foo))
>                ...
>                (current-language orig)))))))

It seems misguided to try to use Scheme code to temporarily switch the
current language to Scheme.  Doesn't this approach presuppose that
Scheme is already the current language?

To be honest, I'm not yet very familiar with how the 'current-language'
parameter can be used, but from a quick search of the source, it seems
clear that the finest granularity that it can possibly be expected to
work on is that of a single top-level form.

Can you help me understand what you are trying to accomplish here?

      Thanks,
        Mark

Reply via email to