Re: keyword question



Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> writes:

"TheBeaNerd" <TheBeaNerd@xxxxxxxxx> 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.
.



Relevant Pages

  • Re: Request for help constructing a simple macro
    ... Isn't an unbound symbol just a `symbol object'? ... Object in Lisp means generally all Lisp data. ... #:FOO ... No package for this symbol. ...
    (comp.lang.lisp)
  • Re: Simple noob question.
    ... (setq key "foo") ... btw, I am thinking classic Lisp, if you have a case sensitive Lisp, uh, ... :foo but just note that it would be diff than:FOO. ... In general you can create a symbol using (intern string [package]), where if you omit the package it defaults to the current package (which can be determined by looking at the special variable *package*. ...
    (comp.lang.lisp)
  • Re: A Question about DEFPACKAGE syntax
    ... Lisp and for not-really-Common-Lisp ... that it's easier to type:foo than to type "FOO". ... "FOO" does not create superficial symbols in the keyword package ...
    (comp.lang.lisp)
  • Re: pop-forum pop language quiz
    ... > in the middle of procedure grom. ... Lisp programmer might expect, because dynamically bound variables ... not the "lvars" foo in grime. ... JG) than the Lisp behaviour. ...
    (comp.lang.pop)
  • Re: Hacking CL into a Lisp-1 (an intro to code-walking)
    ... Because it provides a level of indirection that allows code to pick up ... (funcall 'foo x y z) ... So at best this hack saves you that bit of typing. ... particular, that came up while writing in my book, is the way Lisp ...
    (comp.lang.lisp)