[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about how to check a symbol is bound
From: |
Alaric Snell-Pym |
Subject: |
Re: Question about how to check a symbol is bound |
Date: |
Wed, 28 Jun 2023 16:59:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 |
On 28/06/2023 14:09, felix.winkelmann@bevuta.com wrote:
I guess during expansion identifiers are renamed to some internal gensym
and thus not accessible by name (which is the whole point of a hygienic
macro system).
Oh, and as a side thing, I don't think this is exactly "unhygienic".
Well, the thing I'm trying to do is hygienic, and I'm just being forced
to explore unhygienic techniques to try and recreate that hygienic solution.
After all, we can do:
(define-for-syntax foo 123)
(define-syntax ...
... foo ...)
...and get 123 out of foo at macro expansion time.
What I want to be able to do is:
(define-inner-thing X 123)
(define-outer-thing Y (X))
...and have define-outer-thing's macro expander be able to get 123 from
X. It doesn't really need to know about X as a symbol, and all this
symbol-value nastiness is just a way to try and convert from X passed to
it as a symbol to the value of X, which I'd rather do in a hygienic
manner - if I could!
Of course, we can do something like this:
(define-syntax define-inner-thing
(ir-macro-transformer
...
`(define-syntax ,NAME
(syntax-rules (context1 context2)
((_ context1) ,generated-code-for-context1)
((_ context2) ,generated-code-for-context2))))
...)
(define-syntax define-outer-thing
(syntax-rules ()
((define-outer-thing NAME ((FIELD TYPE) ...))
...(TYPE context1)...
...(TYPE context2)...)))
...and thereby have define-inner-thing use arbitrary low-level macros to
generate arbitrary code snippets and wrap them in a macro binding, that
define-outer-thing can then pull out by invoking the macro. But
define-outer-thing can only splice the generated code into its
expansion, and not do things like combined generated ssql snippets and
ssql->sql them at macro expansion time, which would be nice: if I follow
that path I'll need to expand to code that calls a pure function on
constant arguments at runtime.
felix
--
Alaric Snell-Pym (M0KTN neƩ M7KIT)
http://www.snell-pym.org.uk/alaric/
OpenPGP_signature
Description: OpenPGP digital signature
- Re: Question about how to check a symbol is bound, (continued)
- Re: Question about how to check a symbol is bound, Pan, 2023/06/23
- Re: Question about how to check a symbol is bound, Peter Bex, 2023/06/23
- Re: Question about how to check a symbol is bound, Pan Xie, 2023/06/23
- Re: Question about how to check a symbol is bound, Lassi Kortela, 2023/06/23
- Re: Question about how to check a symbol is bound, Peter Bex, 2023/06/23
- Re: Question about how to check a symbol is bound, Thomas Chust, 2023/06/23
Re: Question about how to check a symbol is bound, Kon Lovett, 2023/06/23