From: Luke Tierney
Subject: question about readtable-case = :invert in ANSI CL
Date: 
Message-ID: <CJJDuI.G77@news.cis.umn.edu>
A quick question for someone familiar with the current CL standard:

Suppose the current readtable has readtable-case set to :invert and a
symbol is entered as

	FOO::bar

Does this refer to the symbol named "bar" in the package named "FOO"
or to the symbol named "BAR" in the package named "foo" (or to
something else entirely)?

CLtL2 seems a bit ambiguous: The third paragraph in 11.2 (first full
paragraph on p. 250) seems to suggest that case conversion is applied
to the symbol name and package name separately, which would lead to
the second interpretation. On the other hand, item 10 at the top of
page 515 seems to suggest that case conversion is to be appplied to
the entire token before separating it into package and symbol name
parts; this suggest the first interpretation.

Thanks,

luke

From: Barry Margolin
Subject: Re: question about readtable-case = :invert in ANSI CL
Date: 
Message-ID: <2h2ifdINNppa@early-bird.think.com>
In article <··········@news.cis.umn.edu> ····@umnstat.stat.umn.edu (Luke Tierney) writes:
>Suppose the current readtable has readtable-case set to :invert and a
>symbol is entered as
>
>	FOO::bar
>
>Does this refer to the symbol named "bar" in the package named "FOO"
>or to the symbol named "BAR" in the package named "foo" (or to
>something else entirely)?
>
>CLtL2 seems a bit ambiguous: The third paragraph in 11.2 (first full
>paragraph on p. 250) seems to suggest that case conversion is applied
>to the symbol name and package name separately, which would lead to
>the second interpretation. On the other hand, item 10 at the top of
>page 515 seems to suggest that case conversion is to be appplied to
>the entire token before separating it into package and symbol name
>parts; this suggest the first interpretation.

The definition of READTABLE-CASE on p.549 also refers to the enter token.

Notice that the text on p.250 is has no change bars, i.e. it is the
original CLtL1 text.  Thus, it predates the notion of READTABLE-CASE, and
doesn't take its effect into account.  Until :INVERT case conversion was
introduced, it was not necessary to distinguish between converting the case
of the entire token and that of the package and symbol parts of the token.

I don't think the text on p.250 corresponds to anything in the dpANS, while
the description on p.549 is very close to the description in the Reader
chapter of the dpANS.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar
From: Tom Almy
Subject: Re: question about readtable-case = :invert in ANSI CL
Date: 
Message-ID: <4947@tekgen.bv.tek.com>
In article <············@early-bird.think.com> ······@think.com (Barry Margolin) writes:
>In article <··········@news.cis.umn.edu> ····@umnstat.stat.umn.edu (Luke Tierney) writes:
>>Suppose the current readtable has readtable-case set to :invert and a
>>symbol is entered as
>>
>>	FOO::bar
>>
>>Does this refer to the symbol named "bar" in the package named "FOO"
>>or to the symbol named "BAR" in the package named "foo" (or to
>>something else entirely)?

>I don't think the text on p.250 corresponds to anything in the dpANS, while
>the description on p.549 is very close to the description in the Reader
>chapter of the dpANS.

In other words, FOO::bar is the symbol bar in the package FOO? This
is very unfortunate because given foo::bar and foo::BAR would refer to
two symbols named BAR in two different packages rather than the "intuitively
obvious" two different symbols, BAR and bar, in the same package. Could
this be something the standard committee overlooked, or is it intentional?
Considering the treatment of |foo|:|bar| versus |foo:bar| it would appear
that the reader should parse the former into three tokens, with the use of
colon being part of the language syntax.



--
Tom Almy
········@tek.com
Standard Disclaimers Apply
From: Barry Margolin
Subject: Re: question about readtable-case = :invert in ANSI CL
Date: 
Message-ID: <2h4l4lINN50a@early-bird.think.com>
In article <····@tekgen.bv.tek.com> ····@wu.labs.tek.com (Tom Almy) writes:
>In other words, FOO::bar is the symbol bar in the package FOO? This
>is very unfortunate because given foo::bar and foo::BAR would refer to
>two symbols named BAR in two different packages rather than the "intuitively
>obvious" two different symbols, BAR and bar, in the same package. Could
>this be something the standard committee overlooked, or is it intentional?

It's possible, since the proposal that added this to the language never
specifically mentioned package names.  However, since the description
specifically refers to "extended token" rather than "symbol name" I think
it was intentional.

:invert mode isn't very intuitive to begin with; even its rationale is hard
to grasp.  It's intended to allow a programming style like:

(let ((Foo 1)
      (FOO 2)
      (foo 3))
  (list Foo FOO foo))

The intent is to allow standard symbols such as LET and LIST to be
referenced using lowercase, while still treating the programmer's symbols
case-sensitively.  The fact that the actual case of the single-case names
is opposite what is written is generally transparent (it only shows up if
you use a function that converts between symbols and strings, such as
SYMBOL-NAME or INTERN).

However, I agree that it gets complicated when package prefixes are
incorporated, and perhaps we didn't consider the ramifications of this
detail of the proposal.  If all those foo's are in the USER package and the
program needs to use prefixes, that code becomes:

(let ((USER::Foo 1)
      (|USER|::FOO 2)
      (user::foo 3))
  ...)

Or if it's in a user-defined package with a mixed-case name, e.g.
MyPackage, it becomes:

(let ((MyPackage::Foo 1)
      (|MyPackage|::FOO 2)
      (|MyPackage|::foo 3))
  ...)

>Considering the treatment of |foo|:|bar| versus |foo:bar| it would appear
>that the reader should parse the former into three tokens, with the use of
>colon being part of the language syntax.

No, it is a single token, which is then interpreted using the rules for
interpreting symbols.  This is similar to the token |foo|bar|baz|, which is
interpreted as the symbol named "fooBARbaz" in the current package
(assuming readtable-case = :upcase).  Vertical bars are simply a shorthand
for putting a backslash before each of the characters between them.  This
is different from most earlier Lisps, which treated the vertical bar and
colon as token delimiters -- in CL they are parts of the syntax of symbols
(just as periods are parts of the syntax of numbers).
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar