[Top][All Lists]

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

Re: local eval

From: Mikael Djurfeldt
Subject: Re: local eval
Date: Wed, 26 Apr 2023 19:25:47 +0200

(However, I suspect that you didn't *really* mean (quote var) in your
original code, or? If you didn't, then of course my simpler syntax-rules
macro isn't what you want.)

On Wed, Apr 26, 2023 at 7:20 PM Mikael Djurfeldt <>

> How about:
> (define-syntax eval-var
>   (syntax-rules ()
>     ((_ var) var)))
> ?
> Then you don't need to import (ice-9 local-eval) and re-export things from
> there.
> Just for elucidation:
> The reason why we chose the syntax-case macro system for Guile was that it
> *both* gives you hygiene *and* quite a lot of control. The reason why the
> original code didn't work (your first post in this thread) is that
> "(the-environment)" was expanded in the lexical context where it was
> written (the Scheme+ module),
> However, syntax-case gives you the ability to insert that identifier into
> the context of the expansion instead:
> (define-syntax eval-var
>   (lambda (x)
>     (syntax-case x ()
>       ((_ var)
>        (with-syntax ((the-environment (datum->syntax #'var
> 'the-environment)))
>          #'(let ((env (the-environment)))
>               (local-eval (quote var) env)))))))
> (It's the datum->syntax form which gives the lexical context of var to
> the-environment.)

reply via email to

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