[plt-scheme] keywords (a backward-incompatible change)
All-
On Oct 2, 2005, at 2:18 AM, Jim Blandy wrote:
> If it's all up to the callee to parse its argument list, and the only
> magic associated with keywords is that they're self-quoting, I guess I
> don't see why they're so much better than quoted symbols, i.e.:
>
> (slide 'center? #t 'tall? #t
> contents ...)
I have wondered this myself, and have implemented keyword-based
binding using symbols as the keyword representation.
When I asked Joe Marshall about it a number of months ago, he told me
that self-quotation *is* essential, because 'x isn't really 'x, its
sugar for (quote x), which means that when you start manipulating
that as syntax, you might end up with the (syntax quote) separated
from the (syntax x). [[ I'm paraphrasing here, and I didn't fully
understand the argument at the time, nor do I fully understand it
now, so forgive me if I'm misquoting you, Joe. ]]
In essence, I think part of the problem might be when you have a
syntax-rules macro that looks like:
(syntax-rules ()
[(fun (foo x) blah)
(func (to foo) (from x) blah)]
[(fun x blah)
(func x blah)])
When you pass in 'y as the second argument to fun, we would end up in
the first clause of the syntax-rules expression, and 'y will get
parsed as two separate pieces, binding foo to quote and x to y. If
we had a keyword representation, :y, then it would be kept as an
atomic value and would end up in the second clause of the syntax-
rules expression.
-Felix
p.s. I second the motion to use the syntax #:foo for keywords instead
of snagging :foo. But I suspect that I will lose on this vote.