guile-devel
[Top][All Lists]
Advanced

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

Should an enclosing let keep the compiler from handling define-module?


From: Rob Browning
Subject: Should an enclosing let keep the compiler from handling define-module?
Date: Wed, 24 Jul 2019 10:27:18 -0500

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

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)))))))

Thanks
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4



reply via email to

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