From: Jonathan LF King
Subject: Unusual characters in symbols, e.g, x�+y�=n , ok in CL ?
Date: 
Message-ID: <xndu271k1wp.fsf@maxwell.math.ufl.edu>
Dear All.  I am writing some number-theory Lisp code, and wonder if I can
safely use

	(defun x�+y�=n (n) ... )

That is, can I safely use "�" as a character in a symbol-name?  [I don't
currently have a real CL, but just have the CLCP (compatibility pkg) in
Emacs.  I did some experiments and it *seemed* that expressions such as

	(setq	mom	'x�+y�=n 
		x�+y�=n	'bob   )

evaluated correctly.  However, given the symbol x�+y�=n directly, Emacs
seemed to use "�" as a separating character and "=n" as a separate symbol.]

  A related question.  Can "?" be used in symbol-names by CL?  Can "�" be
used?	Sincerely, -Jonathan King

PS:  I posted a similar question in ng "gnu.emacs.help", but about Emacs lisp.
-- 
Prof. Jonathan LF King	  Mathematics dept, Univ. of Florida
<······@math.ufl.edu>,	  <http://www.math.ufl.edu/~squash/>

From: Hartmann Schaffer
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n , ok in CL ?
Date: 
Message-ID: <slrn964l04.tbn.hs@paradise.nirvananet>
In article <···············@maxwell.math.ufl.edu>, Jonathan LF King wrote:
>Dear All.  I am writing some number-theory Lisp code, and wonder if I can
>safely use
>
>	(defun x�+y�=n (n) ... )

CLtL2, p.28/29. describes escape rules

either escape each "nonsymbol character" with \, or surround the string
making up your symbol with |, e.g;

(setq mom '|x\xb2+y\xb2=n|)

>
>That is, can I safely use "�" as a character in a symbol-name?  [I don't

should be fine, though i haven't tried | escaped symbols that include \ in
their symbol string

hs
From: Steven M. Haflich
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n 	, ok in CL ?
Date: 
Message-ID: <3A62A035.6E7D519F@pacbell.net>
Hartmann Schaffer wrote:
> 
> >Dear All.  I am writing some number-theory Lisp code, and wonder if I can
> >safely use
> >
> >       (defun x�+y�=n (n) ... )
> 
> CLtL2, p.28/29. describes escape rules
> 
> either escape each "nonsymbol character" with \, or surround the string
> making up your symbol with |, e.g;
> 
> (setq mom '|x\xb2+y\xb2=n|)
> 
> >
> >That is, can I safely use "�" as a character in a symbol-name?  [I don't
> 
> should be fine, though i haven't tried | escaped symbols that include \ in
> their symbol string

I think you may be missing some important points.

Whether something is possible in some CL implementations and whether
it is portable to all comforming implementations are two separate
questions.  The set of standard characters in standard cl is fairly small --
roughly the 7-bit ASCII set.  See the ANS section 2.1.3 Standard Characters.
Clearly your symbol name with superscript characters is not portable CL.
You _might_ get away with it, of course, in a CL that supports full 8-bit
characters _if_ these characters are represented by multi-byte escape
sequences, and if none of the bytes in those sequences look like characters
that terminate names or have other non-constituent syntax, but that could
be a matter of luck.  Also, string lengths will not be computed correctly
and the pretty-printer won't be able to do its thing for multi-byte
escapes -- as far as Lisp (or 8-bit-char C) is concerned, these characters
don't exist and the fact that your input/output media happen to display
them with the multi-byte glyph depends on punning.  Clearly this isn't
the right way to go about this sort of thing.

Some CL implementations do support larger character sets, and this is
allowed by the standard.  You haven't mentioned what encodings you use
(Emacs allows specification per buffer) but for streams to read such
encodings correctly by such a Lisp the stream must be created with the
appropriate external-format (which can be specified as an implementation
dependent keyword argument to open).

Allegro 6.0 supports full 16-bit Unicode, but Unicode is customarily
externalized in various external formats.  UTF-8 is something quite
different from flat 16-bit Unicode.

In such an implementation, all the characters in your example would
be considered constituent characters by the standard readtable (i.e.
not whitespace or escapes or other macro terminating characters such
as parens) and therefore could be incorporated freely in strings and
symbol names.  But codd containing them would probably be portable
to other Unicode-supporting implementations but would not be portable
to all implementations.
From: Paul Foley
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n , ok in CL ?
Date: 
Message-ID: <m23delcpfu.fsf_-_@mycroft.actrix.gen.nz>
On 14 Jan 2001 21:41:17 -0500, Hartmann Schaffer wrote:

> In article <···············@maxwell.math.ufl.edu>, Jonathan LF King wrote:
>> Dear All.  I am writing some number-theory Lisp code, and wonder if I can
>> safely use
>> 
>> (defun x²+y²=n (n) ... )

> CLtL2, p.28/29. describes escape rules

> either escape each "nonsymbol character" with \, or surround the string
> making up your symbol with |, e.g;

> (setq mom '|x\xb2+y\xb2=n|)

No.  Where did the "\xb2" come from?  You can use backslashes to quote
characters that would otherwise terminate the symbol name (spaces, for
example), or to get lower-case characters in the name (with the
default readtable-case), etc., but you then type something like
This\ is\ a\ symbol\ name\ with\ spaces, not This\x20is\x20... -- the
name of that last symbol is "THISx20ISx20..." (with lower-case `x's),
not "THIS IS ..."; and the one you've produced is "xxb2+yxb2=n", which 
is clearly not the same as "X²+Y²=N".

You don't need to use both || and \, except to quote | or \ inside ||.

>> 
>> That is, can I safely use "²" as a character in a symbol-name?  [I don't

I'd expect so, yes.  [But look up SET-SYNTAX-FROM-CHAR for more info.
The standard doesn't say anything about what the syntax of this
character should be by default]

> should be fine, though i haven't tried | escaped symbols that include \ in
> their symbol string

It doesn't ordinarily need escaping.

-- 
Quid enim est stultius quam incerta pro certis habere, falsa pro veris?
                                                                 -- Cicero
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(··@) "actrix.gen.nz>"))
From: Hartmann Schaffer
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n , ok in CL ?
Date: 
Message-ID: <slrn967300.2r6.hs@paradise.nirvananet>
In article <·················@mycroft.actrix.gen.nz>, Paul Foley wrote:
>On 14 Jan 2001 21:41:17 -0500, Hartmann Schaffer wrote:
>
>> In article <···············@maxwell.math.ufl.edu>, Jonathan LF King wrote:
>>> Dear All.  I am writing some number-theory Lisp code, and wonder if I can
>>> safely use
>>> 
>>> (defun x�+y�=n (n) ... )
>
>> CLtL2, p.28/29. describes escape rules
>
>> either escape each "nonsymbol character" with \, or surround the string
>> making up your symbol with |, e.g;
>
>> (setq mom '|x\xb2+y\xb2=n|)
>
>No.  Where did the "\xb2" come from?  You can use backslashes to quote

that's what (squared) looke like under the hood, i.e. when you look at
your post with a text editor.

>characters that would otherwise terminate the symbol name (spaces, for
>example), or to get lower-case characters in the name (with the
>default readtable-case), etc., but you then type something like
>This\ is\ a\ symbol\ name\ with\ spaces, not This\x20is\x20... -- the
>name of that last symbol is "THISx20ISx20..." (with lower-case `x's),
>not "THIS IS ..."; and the one you've produced is "xxb2+yxb2=n", which 
>is clearly not the same as "X�+Y�=N".

that's exactly why i put the cautionary note at the end

>
>You don't need to use both || and \, except to quote | or \ inside ||.
>
>>> 
>>> That is, can I safely use "�" as a character in a symbol-name?  [I don't
>
>I'd expect so, yes.  [But look up SET-SYNTAX-FROM-CHAR for more info.
>The standard doesn't say anything about what the syntax of this
>character should be by default]

as i said before, i haven't the hyperspec accessible right now, but i think
that once you escape a symbol name with | ... |, the backslash looses its
special status when in the reader

>
>> should be fine, though i haven't tried | escaped symbols that include \ in
>> their symbol string
>
>It doesn't ordinarily need escaping.

but in this case it was part of the symbol string

hs
From: Steven M. Haflich
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n 	, ok in CL ?
Date: 
Message-ID: <3A63DFCD.8CE2A71D@pacbell.net>
Hartmann Schaffer wrote:
> 
> as i said before, i haven't the hyperspec accessible right now, but i think
> that once you escape a symbol name with | ... |, the backslash looses its
> special status when in the reader

This is incorrect.  A "single-escape" within a "double-escape" portion of
a symbol name removes any special interpretation from the immediately
following character.  Of course, inside a double-escape there are only two
(sets of) characters with non-constituent meaning: those characters that
themselves have either single- or double-escape syntax.  From ANS
2.2 Reader Algorithm:

9. At this point a token is being accumulated, and an odd number of
   multiple escape characters have been encountered. If at end of file,
   an error of type end-of-file is signaled. Otherwise, a character, y,
   is read, and one of the following actions is performed according to
   its syntax type: 

   If y is a constituent, macro, or whitespace2 character, y is treated
   as a constituent whose only constituent trait is alphabetic2. Y is
   appended to the token being built, and step 9 is repeated. 

   If y is a single escape character, then the next character, z, is read,
   or an error of type end-of-file is signaled if at end of file. Z is
   treated as a constituent whose only constituent trait is alphabetic2.
   Z is appended to the token being built, and step 9 is repeated. 

     If y is a multiple escape character, then step 8 is entered. 

     If y is an invalid character, an error of type reader-error is
     signaled. 

To make a long story interminable, a backslash inside vertical bar syntax
allows the appearance of vertical bar and backslash as symbol name
constituents:

> '|foo\|bar|
|foo\|bar|
From: Paul Foley
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n , ok in CL ?
Date: 
Message-ID: <m21yu4az24.fsf_-_@mycroft.actrix.gen.nz>
On 15 Jan 2001 19:53:12 -0500, Hartmann Schaffer wrote:

> as i said before, i haven't the hyperspec accessible right now, but i think
> that once you escape a symbol name with | ... |, the backslash looses its
> special status when in the reader

No, backslashes still work the same way; but the only characters you
need to quote explicitly are \ and |, since the effect of |...| is to
effectively quote everything else.

>>> should be fine, though i haven't tried | escaped symbols that include \ in
>>> their symbol string
>> 
>> It doesn't ordinarily need escaping.

> but in this case it was part of the symbol string

Doesn't matter; as long as ² is a constituent character, you can name
a symbol foo²bar without quoting it.  If not, you have to quote it as
foo\²bar (or |FOO²BAR|, etc.), not foo\x2bbar (which is FOOx2BBAR)

\x is just a lower-case `x', not something that turns hex digits into
a character.

-- 
In modern physics, the more logical you are, the more wrong you are.
                                                           -- Lama Govinda
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(··@) "actrix.gen.nz>"))
From: Paul Foley
Subject: Re: Unusual characters in symbols, e.g, x²+y²=n , ok in CL ?
Date: 
Message-ID: <m2u271b1ui.fsf_-_@mycroft.actrix.gen.nz>
On 15 Jan 2001 07:25:44 +0000, Erik Naggum wrote:

> * Paul Foley <·······@actrix.gen.nz>
> | Where did the "\xb2" come from?

>   From Emacs Lisp.  \x<hh> is the character with hexadecimal code hh.  In
>   this case, #xb2 happens to be the ISO 8859-1 character code for ².

Oh, I know that (obviously; that's why I substituted \x20 for space).
What I was getting at is that Common Lisp doesn't interpret \xNN in a
symbol name as a hexadecimal value to be replaced with the
corresponding character; it's just a lower-case `x' followed by two
more characters [Emacs Lisp doesn't interpret it this way in symbol
names, either; though it does in strings].

-- 
I have stopped reading Stephen King novels.  Now I just read C code
instead.                                            -- Richard A. O'Keefe

(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(··@) "actrix.gen.nz>"))
From: Jonathan LF King
Subject: Re: Unusual characters in symbols, e.g, x�+y�=n , ok in CL ?
Date: 
Message-ID: <xndofx8k13f.fsf@maxwell.math.ufl.edu>
Thank you all who replied to my query about "�" in a symbolname.  I
didn't follow the details, but the quantity of commentary convinces me
that it isn't worth the trouble (for me), and I will continue to call
the function "x2+y2=n".  Thanks again.		Sincerely, -Jonathan
-- 
Prof. Jonathan LF King	  Mathematics dept, Univ. of Florida
<······@math.ufl.edu>,	  <http://www.math.ufl.edu/~squash/>
From: Cor Gest jr
Subject: Re: Unusual characters in symbols, e.g, x�+y�=n , ok in CL ?
Date: 
Message-ID: <8766jgq9gs.fsf@cleopatra.clsnet.nl>
Erik Naggum <····@naggum.net> writes:

> * Jonathan LF King <······@math.ufl.edu>
> | Thank you all who replied to my query about "�" in a symbolname.  I
> | didn't follow the details, but the quantity of commentary convinces me
> | that it isn't worth the trouble (for me), and I will continue to call
> | the function "x2+y2=n".
> 
>   This is probably goofy, but why x2+y2=n when xx+yy=n seems so much closer
>   to what you really want to express?
> 

I tried in clisp to do this:
 
;(defun x^2+y^2=n ())

which returns X^2+Y^2=N  as the function name.
and the () refers to an lambda-expression.

but i am not shure if the `^' could break anything along the way.

I am just started to learn clisp, so bear my ignorance if this mangles
something else.


cor

-- 
/*    If GNU/LINUX has no solution, you've got the wrong problem    */
/*    Never install Slackware..........You might learn to use IT    */ 
/*    ······@amsat.org                    http://clsnet.dynip.nl    */
From: Jonathan LF King
Subject: Re: Unusual characters in symbols, e.g, x�+y�=n , ok in CL ?
Date: 
Message-ID: <xndwvbt51r7.fsf@maxwell.math.ufl.edu>
Erik Naggum <····@naggum.net> writes:

> 
> * Jonathan LF King <······@math.ufl.edu>
> | Thank you all who replied to my query about "�" in a symbolname.  I
> | didn't follow the details, but the quantity of commentary convinces me
> | that it isn't worth the trouble (for me), and I will continue to call
> | the function "x2+y2=n".
> 
>   This is probably goofy, but why x2+y2=n when xx+yy=n seems so much closer
>   to what you really want to express?

Actually, nothing is wrong with "xx+yy=n", and I may use that.  In
any event, my "lets make it pretty" by calling the routine x�+y�=n
isn't going to generalize well if I want a routine to compute x,y so
that [x^4]+[y^4]=n, since AFAICT, the font sequence �, �, � has no "4".
  Sincerely, -Jonathan
-- 
Prof. Jonathan LF King	  Mathematics dept, Univ. of Florida
<······@math.ufl.edu>,	  <http://www.math.ufl.edu/~squash/>