[plt-scheme] keywords (a backward-incompatible change)

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Oct 2 00:51:46 EDT 2005

On Oct  1, Alex Shinn wrote:
> At Sat, 1 Oct 2005 11:30:47 -0400, Eli Barzilay wrote:
> > 
> > > The idea is a bit of a hack, and doesn't play well with user
> > > extensions to SRFI-42, but basically works.
> > 
> > AFAICT, if you want to define your own generator with srfi42, you can
> > either use a non :prefixed name, or define it as
> > 
> >   (define-syntax \:blah ...)
> 
> I was thinking of third-party extensions, which could not be just
> dropped in and would have to be ported.

The common-case effort will be adding a #k- prefix, but you can always
find situations where this won't work.  But there's nothing really to
do against this, except for waiting for the language to change.
(There are even people on the context insensitive side who will
intentionally spread code that will break in case-sensitive
implementations...  The same can be done with keywords.)


> You also need to be careful what keywords you escape in the body.
> With a keyword argument API, (apply f x '(:key1 val1 :key2 val2)) is
> not unheard of, so you don't want to escape keywords in the first
> position of a list if it's quoted.

I was talking about doing that just for srfi42 macros.  Are there any
functions there?


On Oct  1, Alex Shinn wrote:
> At Sat, 1 Oct 2005 09:53:04 -0400, Eli Barzilay wrote:
> > 
> > And in these discussions, prefix is said to have the advantage of
> > being visually similar to a quote.
> 
> I would consider this a disadvantage, because the prefix quote has
> nothing to do with quote - it's a new literal value.  It has very
> different semantics from quoting.

It is similar in being self-quoting.  But like I said -- this is a
common point, go on cls (and cll) and try it out.


> > (BTW#2, it seems that prefix is a little more popular.)
> 
> As I said, I haven't checked recently, but I know at least Bigloo,
> Chicken and Gambit use suffix, so PLT would not be going for or
> against any semi-standard by adopting colon-suffix keywords.

(Funny that two of the three implementations you mention come from
people that we discussed this with, one accepting both, and one will
accept both.)


On Oct  1, Alex Shinn wrote:
> At Sat, 01 Oct 2005 14:30:38 -0400, Dave Herman wrote:
> > 
> > I just thought of one small point worth considering in the
> > suffix-vs-prefix decision. With suffix-keywords, what would happen
> > to the common pattern of writing
> > 
> >      (require (prefix foo: "foo.ss"))
> 
> Yes, the module system would have to check for this and convert the
> keyword,

That would be a hack.  I would prefer using

  (require (prefix foo\: "foo.ss"))

for such cases (imagine the mess that will happen with implementations
that treat :foo and foo: as the same value).


> but at least it wouldn't affect any user code [...]

Huh?  I think that the damage to current code is roughly the same.


> Prefix vs. Suffix is of course a trade-off as to where your problems
> occur, but colon-prefixes seem to be traditionally used for a wider
> variety of purposes not related to keywords.

My experience makes me reach the opposite conclusion.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.