From: TheBeaNerd
Subject: keyword question
Date: 
Message-ID: <1151634995.027650.186700@i40g2000cwc.googlegroups.com>
What should be the behavior of the following form:

`(: foo)

(note the space)

We have evaluated this on 3 different lisps and
have had 3 different answers:

gcl: ( :|| foo)
ACL: (:foo)
sbcl: <illegal terminating character after a colon>

Do any standards speak to this?

From: Pascal Bourguignon
Subject: Re: keyword question
Date: 
Message-ID: <87bqsbz68y.fsf@thalassa.informatimago.com>
"TheBeaNerd" <··········@gmail.com> writes:

> What should be the behavior of the following form:
>
> `(: foo)
>
> (note the space)
>
> We have evaluated this on 3 different lisps and
> have had 3 different answers:
>
> gcl: ( :|| foo)
> ACL: (:foo)
> sbcl: <illegal terminating character after a colon>
>
> Do any standards speak to this?

First note that: 
http://www.lispworks.com/documentation/HyperSpec/Body/02_ad.htm
says that #\: is a constituent.

and http://www.lispworks.com/documentation/HyperSpec/Body/02_adg.htm
says that spaces are used to separate tokens.

Then, refer to:
http://www.lispworks.com/documentation/HyperSpec/Body/02_b.htm Since
#\: is a constituent, option 7 is selected and a token is read,
consisting of only that character.

Since that token contains a #\: character, we have to choose one of
the highly informal pattern specified on:
http://www.lispworks.com/documentation/HyperSpec/Body/02_ce.htm

Since there's no number that can be written with zero character, and
since it's possible for a symbol to have an empty string as a name, we
could choose the :xxxxx option for a symbol, and interpret : as :||.

Of course, the problem is that we want to allow keywords with names of
length different from 5, notably, of length inferior to 5.  So if we
accept to say that :yes match the pattern :xxxxx, we could as well
accept a length of 0 and say that : match it too.


This version of ACL is definitely wrong.  SBCL interpretation of the
specification is not wrong but you might prefer to choose another,
less strict, implementation...


clisp reads it as (:|| FOO) too:

[175]> '(: foo)
(:|| FOO)
[176]> (export 'cl-user::)
T
[177]> '(cl-user: foo)
(|| FOO)

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Kent M Pitman
Subject: Re: keyword question
Date: 
Message-ID: <uirmiafqz.fsf@nhplace.com>
Pascal Bourguignon <···@informatimago.com> writes:

> "TheBeaNerd" <··········@gmail.com> writes:
> 
> > What should be the behavior of the following form:
> >
> > `(: foo)
> >
> > (note the space)
> >
> > We have evaluated this on 3 different lisps and
> > have had 3 different answers:
> >
> > gcl: ( :|| foo)
> > ACL: (:foo)
> > sbcl: <illegal terminating character after a colon>
> >
> > Do any standards speak to this?
> ...
> Since there's no number that can be written with zero character, and
> since it's possible for a symbol to have an empty string as a name, we
> could choose the :xxxxx option for a symbol, and interpret : as :||.
> ...

Yeah, the normal rule is "tokenize symbol's boundaries first, then
parse it".  So for "foo:bar" it first finds the edges and then splits
it.  '(: foo) contains two potential symbol/numbers, and they have to
be analyzed separately.

Historically, this problem is because the first package system, in
Zetalisp, made colon be a special macro character that only saw the
stuff before it and then read the stuff after it with package bound.
(There was no internal/external distinction, which made it no problem
that binding package was the same as seeing internal symbols; when the
internal/external symbol distinction went in, things got hairier).
In Zetalisp, you could write foo:(a b c) and get (foo:a foo:b foo:c)
and you could write '(foo: a) and get '(foo:a).  In fact, in early code
you could write #+LISPM FOO: A  and have that read as FOO:A on a Lisp 
Machine and as just A on a non-lisp machine.

And there was a bunch of fussing because the Lisp Machine's *features*
(in Zetalisp, not CL) had 3600 or 3670 (model numbers of Lisp Machine) on
them such that people did #+3600 and there was a question about whether
:3600 was a number (Zetalisp read this as:  
  #.(let ((*package* (find-package "KEYWORD"))) (read))3600
and got a number, while most implementations read it as a symbol.

I believe ANSI CL clarified that :3600 a symbol, but it's been a while
since I read it to be sure.  All of the above "fun" I mention just for
color.

But ACL may be accepting (: foo) as (:foo) for Lisp Machine compatibility.