Home > Archive > Scheme > August 2007 > character qualifiers?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
character qualifiers?
|
|
| ballpointpenthief 2007-08-22, 7:11 pm |
| Hello,
So far today I have been writing syntax transformers.
I would like $x to expand into (syntax-object->datum (syntax x))
Does Scheme support this kind of metaprogramming?
(here is an explanation...)
==================================
;; To delay obfuscating my code I start with...
(syntax-case x ()
(a
a))
;; Which then gets corrected...
(syntax-case x ()
(a
(syntax a)))
;; I just found out I can simply write...
(syntax-case x ()
(a
#'x))
;; but my code contains many cases of...
(syntax-case x ()
(a
(syntax-object->datum
#'a)))
;; and I'd like to be able to write something similar to...
(syntax-case x ()
(a $a))
====================
Thanks,
Matt
| |
| Jens Axel Søgaard 2007-08-22, 7:11 pm |
| ballpointpenthief wrote:
> Hello,
> So far today I have been writing syntax transformers.
> I would like $x to expand into (syntax-object->datum (syntax x))
>
> Does Scheme support this kind of metaprogramming?
That's implementation dependent.
If you are willing to declare that $x has a special
expansion, you can in a simple way achieve what you
want. Search for "identifier macro" (for example in
"The Scheme Programming Language" by Dybvig.
If you require that all $-prefixes should expand
in a special way, then it is still doable (at least
in some implementations), but you need to dig deeper
into the implementation documentation.
--
Jens Axel Søgaard
|
|
|
|
|