223 lines
15 KiB
HTML
223 lines
15 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue CHAR-NAME-CASE Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss023_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss024.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss025_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss023_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss024.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss025_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue CHAR-NAME-CASE Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss024.htm">CHAR-NAME-CASE</A><P>
|
|
<B>Forum:</B> Editorial<P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> (p242), <A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> (p243), #\ (p353)<P>
|
|
<B>Category:</B> Clarification<P>
|
|
<B>Edit history:</B> 01-Mar-91, Version 1 by Pitman<P>
|
|
08-Apr-91, Version 2 by Pitman<P>
|
|
<B>Status:</B> X3J13 passed option X3J13-MAR-91 on a 9-3 vote, March 1991.<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
In what case is a char name? Specifically,<P>
|
|
<P>
|
|
1. Which of (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "SPACE"), (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "Space"), (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "space")<P>
|
|
is a legitimate way to name the Space character? [CLtL seems to <P>
|
|
make this clear, but then later says things that make one wonder.]<P>
|
|
<P>
|
|
2. Does (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\Space) yield "Space", "SPACE, or "space" ?<P>
|
|
<P>
|
|
CLtL, p353, says:<P>
|
|
<P>
|
|
#\name reads in a character object whose name is name<P>
|
|
(actually, whose name is (<A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>string-upcase</B></A> name); therefore <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A><P>
|
|
syntax is case insensitive).<P>
|
|
<P>
|
|
This would seem to imply that (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\Space) => "SPACE"<P>
|
|
and further that only because of the syntax does lookup of<P>
|
|
#\Space succeed, which would imply that (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "Space")<P>
|
|
should fail.<P>
|
|
<P>
|
|
CLtL, p243 (for <A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A>), says:<P>
|
|
<P>
|
|
If the name is the same as the name of a character object (as <P>
|
|
determined by <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-equal"><B>STRING-EQUAL</B></A>), that object is returned.<P>
|
|
<P>
|
|
CLtL, p242 (for <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A>), says:<P>
|
|
<P>
|
|
Graphic characters may or may not have names.<P>
|
|
<P>
|
|
This would seem to `license' an implementation to give names to chars<P>
|
|
like "A" and "$" if they wanted. But that can't really work in<P>
|
|
general because "A" and "a" if compared by <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-equal"><B>STRING-EQUAL</B></A> will seem <P>
|
|
the same, when in fact two different characters are almost surely <P>
|
|
implied.<P>
|
|
<P>
|
|
<B>Proposal (CHAR-NAME-CASE:X3J13-MAR-91):<P>
|
|
</B><P>
|
|
Specify that all character names are two or more characters long.<P>
|
|
<P>
|
|
Specify that <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> returns names of characters in the case<P>
|
|
mentioned in the description of <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> (i.e., "Tab", "Page",<P>
|
|
"Rubout", "Linefeed", "Return", "Backspace", "Newline", "Space").<P>
|
|
<P>
|
|
<B>Proposal (CHAR-NAME-CASE:ANY-IN-CAPITALIZE-OUT):<P>
|
|
</B><P>
|
|
1. Define that <A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> is case-sensistive for names one character long,<P>
|
|
but case-insensitive for longer names.<P>
|
|
<P>
|
|
2. Define that if <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> returns a string, that string is either<P>
|
|
a long name (a string of length greater than one) in <P>
|
|
capitalized (i.e., uppercase initial) format<P>
|
|
<A REL=DEFINITION HREF="../Body/a_or.htm#or"><B>OR</B></A> a short name (a string one character long) which contains only<P>
|
|
one character, which has the same character code as the argument<P>
|
|
to <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A>.<P>
|
|
<P>
|
|
Test case:<P>
|
|
<P>
|
|
1. a. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "SPACE") => #\Space<P>
|
|
b. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "Space") => #\Space<P>
|
|
c. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "space") => #\Space <P>
|
|
d. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "A") '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> #\A)) => true<P>
|
|
e. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "a") '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> #\a)) => true<P>
|
|
<P>
|
|
2. a. (<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\Space) "Space") => true<P>
|
|
b. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\a) '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> "a") :test #'<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>) => true<P>
|
|
c. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\A) '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> "A") :test #'<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>) => true<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
A primary purpose of these operators is to support input <P>
|
|
(e.g., the #\ reader macro) and and output (e.g., <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A> and <P>
|
|
<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A>'s ~@C) of characters.<P>
|
|
<P>
|
|
1. It would be confusing for "Space" and "SPACE" to map to different<P>
|
|
characters, and just plain frustrating for one to be valid<P>
|
|
while the other was useless.<P>
|
|
<P>
|
|
2. It is most useful for this to return a known case so that users<P>
|
|
who care about the presentation are saved from calling <A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>STRING-UPCASE</B></A>,<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-capitalize"><B>STRING-CAPITALIZE</B></A>, or <A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-downcase"><B>STRING-DOWNCASE</B></A> even when the result might <P>
|
|
already come back that way. The most common thing to do with a name<P>
|
|
is to print it (e.g., when printing a character), so capitalization<P>
|
|
makes the most sense.<P>
|
|
<P>
|
|
<B>Proposal (CHAR-NAME-CASE:CASE-SENSITIVE):<P>
|
|
</B><P>
|
|
1. Define that <A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> is case-sensitive.<P>
|
|
<P>
|
|
2. Define that <A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> returns the names "Space" and "Newline"<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> "Rubout", "Page", "Tab", "Backspace", "Return", <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> "Linefeed"<P>
|
|
if they are supported by the implementation) in uppercase initial.<P>
|
|
<P>
|
|
3. Define that #\ is case-sensitive.<P>
|
|
<P>
|
|
4. Define that the names "SPACE" and "space" are synonyms for "Space".<P>
|
|
Define that the names "NEWLINE" and "newline" are synonyms for "Newline".<P>
|
|
And likewise for "Rubout", "Page", "Tab", "Backspace", "Return",<P>
|
|
and "Linefeed" if they are supported.<P>
|
|
<P>
|
|
Test case:<P>
|
|
<P>
|
|
1. a. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "SPACE") => #\Space<P>
|
|
b. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "Space") => <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
c. (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "Space") => <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
d. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "A") '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> #\A)) => true<P>
|
|
e. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "a") '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> #\a)) => true<P>
|
|
<P>
|
|
2. a. (<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\Space) "SPACE") => true<P>
|
|
b. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\a) '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> "a") :test #'<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>) => true<P>
|
|
c. (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> #\A) '(<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> "A") :test #'<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>) => true<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
1. This leaves flexibility for other languages or notations<P>
|
|
which have long names for glyphs that make some kind of case.<P>
|
|
e.g.,<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "ALPHA")<P>
|
|
might want to be distinguished from<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> "alpha")<P>
|
|
in Greek, with the former representing an uppercase character<P>
|
|
and the latter representing a lowercase character.<P>
|
|
<P>
|
|
The choice of uppercase initial means that when printing #\xxx,<P>
|
|
no case conversion is needed. Saving the time and in some<P>
|
|
implementations the space required to do case conversion.<P>
|
|
<P>
|
|
2. This assures that (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> x)) => x, <P>
|
|
when (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> x) is not <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>.<P>
|
|
<P>
|
|
3. This is necessary in order for #\ALPHA and #\alpha to be <P>
|
|
distinguishable.<P>
|
|
<P>
|
|
4. This keeps compatibility concerns for existing usages of<P>
|
|
#\space, #\SPACE, #\newline, and #\NEWLINE from becoming<P>
|
|
the overwhelming issue.<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Symbolics Genera implements ANY-IN-CAPITALIZE-OUT.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Both proposals are probably relatively cheap to implement.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
ANY-IN-CAPITALIZE-OUT is probably very low cost because it is <P>
|
|
more tolerant of deviations which almost surely already exists between<P>
|
|
implementations, and among users who have made various assumptions<P>
|
|
about what implementations might or should do.<P>
|
|
<P>
|
|
CASE-SENSITIVE is a slightly incompatible change, but<P>
|
|
probably a lot of programs don't use either of these functions.<P>
|
|
Of those that do, some usages don't depend on anything other<P>
|
|
than that (<A REL=DEFINITION HREF="../Body/f_name_c.htm#name-char"><B>NAME-CHAR</B></A> (<A REL=DEFINITION HREF="../Body/f_char_n.htm#char-name"><B>CHAR-NAME</B></A> x)) will work. In any case, most<P>
|
|
applications that uses these are probably fairly easily to check<P>
|
|
by hand even though mechanical checking probably would not work <P>
|
|
very well.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Divergence among implementations. Potential portability problems<P>
|
|
from skews of interpretations. New implementations would not know<P>
|
|
clearly what their rights and responsibilities were.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
A clearer specification.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
ANY-IN-CAPITALIZE-OUT is less aesthetic because it has a special<P>
|
|
case for one-character strings.<P>
|
|
<P>
|
|
CASE-SENSITIVE is generally more aesthetic.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
KMP thinks that mostly it's a good idea to resolve this clearly one<P>
|
|
way or another, and isn't incredibly fussy about the details. He has<P>
|
|
a mild preference for proposal CASE-SENSITIVE because it leaves the<P>
|
|
greatest flexibility to the international community which has the<P>
|
|
English alphabet forced upon them all too often already.<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|