From: Matthew X. Economou
Subject: Case of a reader macro character
Date: 
Message-ID: <u1wk2a2l1.fsf@irtnog.org>
Does the Common Lisp reader ignore the case of reader macro
characters?  If I understand the language specification correctly, the
Lisp reader ignores the case of the second character in a dispatch
reader macro, but nothing in section 2.1.4.4 (Macro Characters) or in
section 23.2 (The Reader Dictionary) leads me to believe that the Lisp
reader ignores the case of macro or dispatching macro characters.  If
this is the correct reading of the spec, why does the specification
require the reader to ignore the case of the second character in a
dispatching macro?

Best wishes,
Matthew

-- 
"Rogues are very keen in their profession, and know already much more
than we can teach them respecting their several kinds of roguery."
  - A. C. Hobbs in _Locks and Safes_ (1853)

From: Pascal Bourguignon
Subject: Re: Case of a reader macro character
Date: 
Message-ID: <87r6s18mxm.fsf@voyager.informatimago.com>
"Matthew X. Economou" <···············@irtnog.org> writes:

> Does the Common Lisp reader ignore the case of reader macro
> characters?  

No, it does not.


> If I understand the language specification correctly, the
> Lisp reader ignores the case of the second character in a dispatch
> reader macro, but nothing in section 2.1.4.4 (Macro Characters) or in
> section 23.2 (The Reader Dictionary) leads me to believe that the Lisp
> reader ignores the case of macro or dispatching macro characters.  If
> this is the correct reading of the spec, why does the specification
> require the reader to ignore the case of the second character in a
> dispatching macro?

But in line with the default case folding readtable-case setting, the
standard specifies actually two reader macros for each one, the same
function being bound to the lower and upper case version of the
letters.

If you change the reader macro function of only one case, you still
get the other reader macro function on the other case.


    2.4.8 Sharpsign

    Sharpsign is a non-terminating dispatching macro character. It
    reads an optional sequence of digits and then one more character,
    and uses that character to select a function to run as a reader
    macro function.

    The standard syntax includes constructs introduced by the #
    character. The syntax of these constructs is as follows: a
    character that identifies the type of construct is followed by
    arguments in some form. If the character is a letter, its case is
    not important; #O and #o are considered to be equivalent, for
    example.


This applies only for the standard #\# dispatch macros.



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
        Un chat errant
se soulage
        dans le jardin d'hiver
                                        Shiki
From: Kalle Olavi Niemitalo
Subject: Re: Case of a reader macro character
Date: 
Message-ID: <87y7m9jcjn.fsf@Astalo.kon.iki.fi>
Pascal Bourguignon <···@informatimago.com> writes:

> But in line with the default case folding readtable-case setting, the
> standard specifies actually two reader macros for each one, the same
> function being bound to the lower and upper case version of the
> letters.
>
> If you change the reader macro function of only one case, you still
> get the other reader macro function on the other case.

The letters are not macro characters in the standard readtable,
so I assume you mean the letters used after the # dispatching
macro character.  In which case, note this in the specification
of SET-DISPATCH-MACRO-CHARACTER:

# If sub-char is a lowercase letter, it is converted to its
# uppercase equivalent.

So, you cannot define separate reader macro functions for
uppercase and lowercase sub-characters, even if you use a
dispatching macro character other than #.  There are surely ways
to work around the restriction though, e.g. by making the reader
macro function examine its sub-character parameter, or by using
just SET-MACRO-CHARACTER and rewriting the dispatching yourself.

As for the case sensitivity of macro characters (as opposed to
sub-characters), if you're defining letters as reader macros, I
think you should reconsider whether to use the Lisp reader for
your input syntax at all.
From: Pascal Bourguignon
Subject: Re: Case of a reader macro character
Date: 
Message-ID: <87abyp824m.fsf@voyager.informatimago.com>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> Pascal Bourguignon <···@informatimago.com> writes:
>
>> But in line with the default case folding readtable-case setting, the
>> standard specifies actually two reader macros for each one, the same
>> function being bound to the lower and upper case version of the
>> letters.
>>
>> If you change the reader macro function of only one case, you still
>> get the other reader macro function on the other case.
>
> The letters are not macro characters in the standard readtable,
> so I assume you mean the letters used after the # dispatching
> macro character.  In which case, note this in the specification
> of SET-DISPATCH-MACRO-CHARACTER:
>
> # If sub-char is a lowercase letter, it is converted to its
> # uppercase equivalent.
>
> So, you cannot define separate reader macro functions for
> uppercase and lowercase sub-characters, even if you use a
> dispatching macro character other than #.  There are surely ways
> to work around the restriction though, e.g. by making the reader
> macro function examine its sub-character parameter, or by using
> just SET-MACRO-CHARACTER and rewriting the dispatching yourself.

I stand corrected.


> As for the case sensitivity of macro characters (as opposed to
> sub-characters), if you're defining letters as reader macros, I
> think you should reconsider whether to use the Lisp reader for
> your input syntax at all.

Indeed.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
        Un chat errant
se soulage
        dans le jardin d'hiver
                                        Shiki