[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
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.)
- local eval, Damien Mattei, 2023/04/24
- Re: local eval, Robby Zambito, 2023/04/24
- Message not available
- Re: local eval, Damien Mattei, 2023/04/24
- Re: local eval, Damien Mattei, 2023/04/26
- Re: local eval, Robby Zambito, 2023/04/26
- Re: local eval,
Mikael Djurfeldt <=
- Re: local eval, Mikael Djurfeldt, 2023/04/26
- Re: local eval, Damien Mattei, 2023/04/26
- Re: local eval, Damien Mattei, 2023/04/27