[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:20:05 +0200

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

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
         #'(let ((env (the-environment)))
              (local-eval (quote var) env)))))))

(It's the datum->syntax form which gives the lexical context of var to

reply via email to

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