1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss273_w.htm
2024-04-01 10:24:07 +02:00

215 lines
13 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 PRINT-CASE-PRINT-ESCAPE-INTERACTION 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/iss272_w.htm">
<LINK REL=UP HREF="../Issues/iss273.htm">
<LINK REL=NEXT HREF="../Issues/iss274_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/iss272_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss273.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss274_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue PRINT-CASE-PRINT-ESCAPE-INTERACTION Writeup</H2>
<PRE><B>Status:</B> proposal VERTICAL-BAR-RULE-NO-UPCASE passed, Jun 89 X3J13<P>
<P>
<B>Issue:</B> <A HREF="iss273.htm">PRINT-CASE-PRINT-ESCAPE-INTERACTION</A><P>
<B>Forum:</B> Cleanup<P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> (pp370-371), <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> (pp372), <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A><P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit history:</B> 26-Jan-89, Version 1 by Pitman<P>
<P>
<B>Problem Description:<P>
</B><P>
The wording on page 372 of CLtL uses fuzzy terms that make it hard<P>
to tell if <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> interacts with <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A>.<P>
<P>
Paragraph 1 of the description of <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> says &quot;This variable<P>
controls the case (upper, lower, or mixed) in which to print any<P>
uppercase characters in the names of symbols when vertical-bar<P>
syntax is used.&quot;<P>
<P>
Paragraph 2 begins with the seemingly unambiguous statement &quot;Lowercase<P>
characters in the internal print name are always printed in lowercase&quot;<P>
but then goes on to muddy the water by saying &quot;and are preceded by<P>
a single escape character or enclosed by multiple escape characters&quot;.<P>
This escaping presumably only happens in <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> T mode, which<P>
leads one to wonder if other parts of the <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> description are<P>
implicitly controlled by <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> as well.<P>
<P>
The function <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A> is affected by implication.<P>
<P>
<B>Proposal (PRINT-CASE-PRINT-ESCAPE-INTERACTION:LIKE-PRIN1):<P>
</B><P>
Define that <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> cases characters the same as <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A> would.<P>
<P>
<B>Proposal (PRINT-CASE-PRINT-ESCAPE-INTERACTION:LIKE-WRITE-STRING):<P>
</B><P>
Define that <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> has an effect only when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> is T.<P>
When <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, <A REL=DEFINITION HREF="../Body/f_wr_stg.htm#write-string"><B>WRITE-STRING</B></A> is used directly.<P>
<P>
<B>Proposal (PRINT-CASE-PRINT-ESCAPE-INTERACTION:VERTICAL-BAR-RULE-NO-UPCASE):<P>
</B><P>
Define that <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> has an effect at all times when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A><P>
is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. Define that <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> also has an effect when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A><P>
is T unless inside an escape context (i.e., unless between vertical bars<P>
or after a slash). Under no circumstance is any character which was <P>
lowercase in the internal representation ever presented as uppercase<P>
due to <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A>.<P>
<P>
<B>Proposal (PRINT-CASE-PRINT-ESCAPE-INTERACTION:VERTICAL-BAR-RULE-PERMIT-UPCASE):<P>
</B><P>
Like VERTICAL-BAR-RULE-NO-UPCASE, but permit <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> to upcase<P>
lowercase characters in the <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> case since preservation of<P>
Lisp syntax is not important there.<P>
<P>
<B>Proposal (PRINT-CASE-PRINT-ESCAPE-INTERACTION:EXPLICITLY-VAGUE):<P>
</B><P>
Specify that the effect of <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
is implementation-dependent.<P>
<P>
<B>Test Case:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> ((RESULT '()) (TABWIDTH 12))<P>
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>DOLIST</B></A> (<A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> '(|x| |FoObAr| |fOo|))<P>
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> ((TAB -1))<P>
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> T &quot;~&amp;&quot;)<P>
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>DOLIST</B></A> (ESCAPE '(T <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>))<P>
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>DOLIST</B></A> (<A REL=DEFINITION HREF="../Body/m_case_.htm#case"><B>CASE</B></A> '(:UPCASE :DOWNCASE :CAPITALIZE))<P>
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> T &quot;~VT&quot; (* (<A REL=DEFINITION HREF="../Body/m_incf_.htm#incf"><B>INCF</B></A> TAB) TABWIDTH))<P>
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> :ESCAPE ESCAPE :CASE <A REL=DEFINITION HREF="../Body/m_case_.htm#case"><B>CASE</B></A>))))))<P>
<P>
For each of the following, two clusters of output is shown. The first is<P>
how an implementation which leans heavily on vertical bars might work.<P>
The second is how an implementation which leans heavily on slash might<P>
work. In fact, other interpretations are possible (mixing slash and <P>
vertical bar). These examples are not an exhaustive analysis of the <P>
implications of each proposal.<P>
<P>
Possible outputs under LIKE-PRIN1:<P>
<P>
|x| |x| |x| x x x<P>
|FoObAr| |FoObAr| |FoObAr| FoObAr FoObAr FoObAr<P>
|fOo| |fOo| |fOo| fOo fOo fOo<P>
<P>
\x \x \x x x x<P>
F\oO\bA\r f\oo\ba\r F\oo\ba\r FoObAr foobar Foobar <P>
\fO\o \fo\o \fo\o fOo foo foo<P>
<P>
Possible output under LIKE-WRITE-STRING:<P>
<P>
|x| |x| |x| x x x<P>
|FoObAr| |FoObAr| |FoObAr| FoObAr FoObAr FoObAr<P>
|fOo| |fOo| |fOo| fOo fOo fOo<P>
<P>
\x \x \x x x x<P>
F\oO\bA\r f\oo\ba\r F\oo\ba\r FoObAr FoObAr FoObAr<P>
\fO\o \fo\o \fo\o fOo fOo fOo<P>
<P>
Possible output under VERTICAL-BAR-RULE-NO-UPCASE:<P>
<P>
|x| |x| |x| x x x<P>
|FoObAr| |FoObAr| |FoObAr| FoObAr foobar Foobar<P>
|fOo| |fOo| |fOo| fOo foo foo<P>
<P>
\x \x \x x x x<P>
F\oO\bA\r f\oo\ba\r F\oo\ba\r FoObAr foobar Foobar<P>
\fO\o \fo\o \fo\o fOo foo foo<P>
<P>
Possible output under VERTICAL-BAR-RULE-PERMIT-UPCASE:<P>
<P>
|x| |x| |x| X x X<P>
|FoObAr| |FoObAr| |FoObAr| FOOBAR foobar Foobar<P>
|fOo| |fOo| |fOo| FOO foo Foo<P>
<P>
\x \x \x X x X<P>
F\oO\bA\r f\oo\ba\r F\oo\ba\r FOOBAR foobar Foobar<P>
\fO\o \fO\o \fO\o FOO foo Foo<P>
<P>
<B>Rationale:<P>
</B><P>
It's silly for implementations to vary on this point.<P>
<P>
<B>Current Practice:<P>
</B><P>
A strict reading of CLtL suggests that probably VERTICAL-BAR-RULE-NO-UPCASE<P>
is the most correct. <P>
<P>
Symbolics Genera doesn't do any of these. It was trying to do <P>
VERTICAL-BAR-NO-UPCASE, but it had a bug which was about to be fixed when<P>
this issue was raised.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Probably trivial.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Negligible in most cases. Probably very few users depend on this.<P>
Those who do depend on it probably do so because they think the<P>
behavior doesn't vary and probably don't get the portable behavior they<P>
expect.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
Gratuitous variation between implementations.<P>
<P>
<B>Benefits:<P>
</B><P>
Cost of non-adoption is avoided.<P>
<P>
<B>Aesthetics:<P>
</B><P>
Anything that makes the language tighter probably improves aesthetics.<P>
<P>
Only VERTICAL-BAR-RULE-PERMIT-UPCASE and LIKE-WRITE-STRING have really<P>
useful behaviors in the :ESCAPE <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> situation. Of these, perhaps only<P>
VERTICAL-BAR-RULE-PERMIT-UPCASE is really visually pleasant.<P>
<P>
<B>Discussion:<P>
</B><P>
Pitman doesn't think the particular choice is very important. He just<P>
wants the issue to be resolved. His slight preference is for<P>
VERTICAL-BAR-RULE-PERMIT-UPCASE, then LIKE-WRITE-STRING, then either<P>
of LIKE-PRIN1 or VERTICAL-BAR-RULE-NO-UPCASE. He sees no reason to go<P>
with EXPLICITLY-VAGUE unless we deadlock.<P>
<P>
Michael Greenwald, who raised the issue at Symbolics, doesn't have<P>
a preference either but believes that CLtL (perhaps unintentionally)<P>
leans toward VERTICAL-BAR-RULE-NO-UPCASE.<P>
<P>
-----<P>
Additional Discussion from CL-Cleanup:<P>
<P>
David Gray responds:<P>
&gt; Possible output under VERTICAL-BAR-RULE-NO-UPCASE:<P>
&gt; <P>
&gt; |x| |x| |x| x x x<P>
&gt; |FoObAr| |FoObAr| |FoObAr| FoObAr foobar Foobar<P>
&gt; |fOo| |fOo| |fOo| fOo foo foo<P>
This is exactly what the Explorer does.<P>
<P>
There are several options for this issue, but if you're looking for one<P>
to focus on, VERTICAL-BAR-RULE-NO-UPCASE is probably the one we'll push<P>
if this issue comes up for discussion since it is believed most compatible<P>
with current practice.<P>
-kmp<P>
<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>