Re: Problem of implicit quasiquote
Marc Nieper-Wißkirchen 29 Jun 2020 06:30 UTC
Am So., 28. Juni 2020 um 23:52 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> Oh by the way, nested quasiquote isn't always occur in the macro context. If I want to write out a code fragment into a file or a network stream (which I do often), with some variable parts, I naturally use quasiquote.
>
> (write `(define (foo ...) ,variable-part ...))
>
> Usually I copy&paste a working code snippet, add quasiquote in front, and modify the variable parts. If the pasted code includes unpaired unquotes, I have to take care of them, too. Again, it's just an annoyance, one that could've been avoided by a consistent design choice.
I understand. One approach in the right direction, I think, would be
to make quasiquote a bit more flexible. Quasiquote maintains a nesting
level and it makes sense to be able to set it initially to something
different than 0. E.g., we could have a macro `(qq ...)' that
increases the nesting level by one during the expansion of `...'
without actually producing a quasiquote.
Example:
(qq `(1 2 ,x))
would evaluate to (1 2 ,x).
Such a qq macro can be implemented portably with syntax parameters,
but a simple native implementation should be possible as well.
The alternative approach to allow `qq' as auxiliary syntax inside
quasiquote has the problem that is in not backward compatible and we
may run into problems if we want to produce qq.