On 2006-04-29, Pascal Bourguignon wrote:
> Stuart Sierra writes:
>> I was thinking, as I wrote about colon syntax (glad people liked
>> it, by the way) that it would be helpful to explain the various
>> ways of identifying symbols by name when creating packages and the
>> like.  Many standard macros accept 1) normal interned symbols, 2)
>> keyword symbols, 3) uninterned symbols, or 4) strings.  I think the
>> HyperSpec calls these arguments "designators."
>> 
>> It's not always clear which form one should use, and different
>> styles abound.  Is there a "standard" way?
>
> Well, it works by elimination.
[snip]
> Since writing a keyword is easier than writing a string, for
> interactive use, it's acceptable to use keywords instead of strings,
> but in programs, I always use strings, to avoid growing indefinitely
> the KEYWORD package.

Note that this relies on some standard readtable assumptions.  In
particular, the reader usually upcases symbols

  this => THIS
  ThIs => THIS
  THIS => THIS

so when you use strings you say "THIS", but when you use symbols (be
they interned, un-interned, or keyword), the reader does whatever it
does.

This can cause you trouble in some non-standard Lisps' "standard" (for
them) readtable which does no case conversion

  this => |this|
  ThIs => |ThIs|
  THIS => |THIS|

which is why, for example, Slime[1] had to change from using "STRINGS"
to using #:uninterned-symbols, so it would work with Franz's[1]
"modern mode".

Another vote on keywords: they only "pollute" the keyword package of
the image you compile in.  If you compile to a fasl, restart, and then
load the fasl, that doesn't pollute the keyword package.  I think
Peter already mentioned this.

I tend to use uninterned keywords for my DEFPACKAGEs.

-- Larry


[1] (I think)


_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to