[Openmcl-devel] Error on macro character after sharpsign colon

Gary Byers gb at clozure.com
Mon Jan 25 21:56:04 UTC 2010


Note that:

'#:!abc => error in CCL, CLISP (at least), accepted in LW, SBCL (at least)

'#:a!bc = #:a!bc in all implementations that I looked at.

The spec says:

"A non-terminating macro character is treated as a constituent when
it appears in the middle of an extended token being accumulated."

(An initial macro character would cause the function associated with
that character to be called in the standard reader algorithm describted
in section 2.2; a token that begins with an unescaped macro character
would not have "the syntax of a symbol.")

The spec says that the <<symbol-name>> following #:"must have the
syntax of a symbol"; I think that I'd rather have the reader complain
when this is violated than quietly accept invalid/undefined syntax.

Note that #: doesn't just call READ and hope that the result is
a symbol whose name can be used to construct an uninterned symbol;
among other things, that strategy might cause a symbol to be interned
in the current package, possibly introducing conflicts in the process
of doing so.  The #\! in your example can't invoke a macro function
and isn't a constituent character when used at the beginning of a
token, so the differing behavior you see seems to just be a matter
of whether implementations check for that case.




On Mon, 25 Jan 2010, Terje Norderhaug wrote:

> CLZ fails to read an uninterned symbol if the sharpsign colon is
> followed by a macro character. Is this a bug or correct behavior? I
> got no wiser by reading the hyperspec, but presume it's in there
> somewhere:
>
>    http://www.lispworks.com/documentation/lw50/CLHS/Body/02_b.htm
>
> Replicate by evaluating the following:
>
> (defun symbol-reader (stream char)
>    (declare (ignore char))
>    (read stream t nil t))
>
> (set-macro-character #\! #'symbol-reader T)
>
> '!abc
> => ABC
>
> '#:!abc
> => Reader error: Illegal symbol syntax.
>
> Backtrace leads to #'read-symbol-token in the l1-reader.
>
> LispWorks (5.0 Personal) reads '#:!abc without reporting an error.
> Which implementation is right?
>
> -- Terje Norderhaug
>   terje at in-progress.com
>
>
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list