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

From: Alex Shinn (foof at synthcode.com)
Date: Sat Oct 1 23:40:11 EDT 2005

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.  Also, in addition to
extending the generators you may want to add your own comprehensions,
which do not always expand into do-ec (notably first-ec in the
reference implementation does not, because it wants to be able to
terminate early).  Thus users would need to know the API to escaping
keywords if they write their own comprehensions.

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.  More generally, the body may
contain arbitrary macro expansions, such that you can't always know
when a keyword should be escaped.  The Gauche implementation (mostly
because it evolved out of a more limited syntax-rules form) alleviates
this somewhat by only escaping known generator keywords, though this
of course makes extensions more problematic.

In practice so long as you're careful in your own code and port any
third party extensions you're not likely to encounter problems, but
it's fundamentally a hack and an incomplete solution.


Posted on the users mailing list.