Sent from Mail for Windows

From: spacecadet
Sent: Wednesday, 24 July 2024 19:11
To: Taylan Kammer; guile-devel@gnu.org
Subject: Re: Lexically bound macro, with lexically bound transformer

> I think the guile-user list might be more appropriate.

Noted

>    (let-syntax ((outer (lambda (x) #'(+ 1 2))))
>      (let-syntax ((inner (lambda (x) (outer x))))
>        (inner)))

That works, but I guess this isn't possible then

(lambda* (#:key outer)
   (let-syntax ((inner outer))
     (inner ...)))

Since that would require evaluating run-time code at compile-time

>Is there a way to write a macro that's expanded at run-time?

With (local-eval #'(insert expression to be done at run-time) 
(the-environment)), yes.
Caveat (from manual):

>Note that the current implementation of (the-environment) only captures 
>“normal” lexical bindings, and pattern variables bound by syntax-case. It does 
>not currently capture local syntax transformers bound by let-syntax, 
>letrec-syntax or non-top-level define-syntax forms. Any attempt to reference 
>such captured syntactic keywords via local-eval or local-compile produces an 
>error.

The question is: why would you do that?

Best regards,
Maxime  Devos

Reply via email to