guile-devel
[Top][All Lists]
Advanced

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

Re: Should an enclosing let keep the compiler from handling define-modul


From: Mark H Weaver
Subject: Re: Should an enclosing let keep the compiler from handling define-module?
Date: Mon, 05 Aug 2019 14:04:04 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Hi Rob,

Rob Browning <address@hidden> 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

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