[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mon, 15 Mar 2010 15:00:48 -0700
I've added `keyword' objects to MIT Scheme in a way that I hope
keeps everyone happy. A keyword is a self-evaluating symbolic
token, much like a symbol, but it never needs quoting because it
can never mean anything but itself.
The reading and printing of keywords is controlled by the variable
*keyword-style*, which can be #f or one of these symbols:
cl, dsssl, srfi-88, both
If *keyword-style* is #F (the default), then there is no way to
read keywords, and they are printed as #[keyword foo].
If *keyword-style* is 'cl, then tokens with a leading colon are
considered keywords and keywords are printed with a leading colon.
Symbols with a leading colon are printed with vertical-bar quotes
and you can create symbols with leading colons by using vertical-bar
If *keyword-style* is 'srfi-88, then tokens with a trailing colon are
considered keywords and keywords are printed with a trailing colon.
Symbols with a trailing colon are printed with vertical-bar quotes
and you can create symbols with trailing colons by using vertical-bar
'dsssl is a synonym for 'srfi-88
If *keyword-style* is 'both, then either syntax is acceptable for reading,
but the cl syntax will be used in printing. (Putting a colon on both ends
would be weird, so don't.)
The way quoting is currently implemented on symbols makes it hard
to determine if the quotation occurs before or after the first character
or the final character, so non-standard keywords like :|a weird keyword|
end up being interpreted as symbols.
I find these things to be very pragmatic for use in large, complex systems.
I prefer the Common Lisp style with the leading colon because it is easier
to see the keywords. The trailing colon syntax is cute, but the nifty examples
that are shown, like this:
(tcltk-frame relief: 'ridge
just don't look anywhere near as good when the *values* are keywords, which
they often are.
option: default: name: none:)
The PLT syntax of #:key is just plain stupid.
Re: [MIT-Scheme-devel] Keywords, Taylor R Campbell, 2010/03/16
Re: [MIT-Scheme-devel] Keywords, Joe Marshall, 2010/03/19
- [MIT-Scheme-devel] Keywords,
Joe Marshall <=