[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] What happened to (UNQUOTE <expression> ...)

On Tue, May 3, 2011 at 7:30 PM, Jim Rees <jimreesma@x> wrote:
>> and for consistency:
>> > (quote 1 2) => 1 2 (two values inserted in the calling form or the
>> > interactive session)
>> > (quote) => nil (no value)
> Whoa - hold the door.    What are these for?    Letting (unquote ...) and
> (unquote-splicing ....) wrap zero or multiple forms is fine when in a
> suitable context -- and there are some useful things you can do with it --
>  but what purpose would be served by doing the same for (quote ...) ?

I only proposed it for consistency with multiple operand quasiquote
(if we ever decide to introduce it).

I agree with Peter's point that this may require macros that may
expand into multiple forms so it's probably too hard to add to the
spec at this time. In my case it wasn't an issue as I implement
quasiquote as a built-in syntax.

There are actually several reasons for having such capability:

1. (one I mentioned before) Is it just me who thinks that it is a bad
idea to have same quasiquote forms expand correctly in one context and
fail in another?
2. You could write a macro that expands into multiple forms, eg:
   (some-procedure (macro-apply some-contents))
2a. As a performance optimization. Imagine that "macro-apply" expands
to some complex expression. It is usually cheaper to evaluate:
   (some-procedure (macro-apply some-contents))
   (some-procedure (macro-apply-car some-contents) (macro-apply-cadr
some-contents) (macro-apply-caddr some-contents))

I don't really propose any changes to R7RS. Just wanted to share my
opinion that:
- R5RS's quasiquote is somewhat restricted from the user-point of view
but it is at least consistent (as in: unquote-splicing is only valid
in a list context),
- R6RS's quasiquote semantics are extended but we pay for this with
less obvious corner cases.
- We could potentially extend the semantics even further and make it
consistent again if we chose to have multiple valued quasiquote forms.


Scheme-reports mailing list