197 lines
9.8 KiB
HTML
197 lines
9.8 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 SHARP-STAR-DELIMITER 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/iss316_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss317.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss318_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/iss316_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss317.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss318_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue SHARP-STAR-DELIMITER Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss317.htm">SHARP-STAR-DELIMITER</A><P>
|
|
<B>Forum:</B> Editorial<P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/v_rd_sup.htm#STread-suppressST"><B>*READ-SUPPRESS*</B></A> (p345), #* (p355)<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit history:</B> 05-Mar-91, Version 1 by Pitman<P>
|
|
15-Mar-91, Version 2 by Pitman<P>
|
|
<B>Status:</B> For X3J13 consideration<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
What constitutes a delimiter at the end of #* ?<P>
|
|
<P>
|
|
In the description of #* on p355, CLtL says:<P>
|
|
<P>
|
|
``A series of binary digits (0 and 1) preceded by #* is read <P>
|
|
as a simple <A REL=DEFINITION HREF="../Body/t_bt_vec.htm#bit-vector"><B>bit-vector</B></A>. ... If an unsigned decimal integer <P>
|
|
appears between the # and *, it specifies explicitly the <P>
|
|
length of the vector. In that case, it is an error if too<P>
|
|
many bits are specified, and if too few are specified the <P>
|
|
last one (it is an error if there are none in this case) is<P>
|
|
used to fill all remaining elements of the <A REL=DEFINITION HREF="../Body/t_bt_vec.htm#bit-vector"><B>bit-vector</B></A>.<P>
|
|
... The notation #* denotes an empty <A REL=DEFINITION HREF="../Body/t_bt_vec.htm#bit-vector"><B>bit-vector</B></A>, as does<P>
|
|
#0* (which is legitimate because it is not the case that<P>
|
|
too few elements are specified.)''<P>
|
|
<P>
|
|
This seems to imply that the bit vector ends when the sequence<P>
|
|
of 0's and 1's ends.<P>
|
|
<P>
|
|
In the discussion of <A REL=DEFINITION HREF="../Body/v_rd_sup.htm#STread-suppressST"><B>*READ-SUPPRESS*</B></A> on p345, it says:<P>
|
|
<P>
|
|
``The #* construction always scans over a following token and<P>
|
|
produces the value <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. It will not signal an error even if<P>
|
|
the token does not consist solely of the characters 0 and 1.''<P>
|
|
<P>
|
|
This seems to imply that the bit vector ends at the first normal<P>
|
|
delimiter.<P>
|
|
<P>
|
|
<B>Proposal (SHARP-STAR-DELIMITER:NORMAL-DELIMITER):<P>
|
|
</B><P>
|
|
Specify that a bit vector is delimited like any normal numeric<P>
|
|
token, and that an error of type <A REL=DEFINITION HREF="../Body/e_rder_e.htm#reader-error"><B>READER-ERROR</B></A> is signalled if all<P>
|
|
the characters in the token are not 0's and 1's. Clarify<P>
|
|
that | and \ are not permitted as part of the token.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This will seem most natural to people already familiar with the <P>
|
|
parsing of other tokens in the language. This is most consistent<P>
|
|
with the wording in <A REL=DEFINITION HREF="../Body/v_rd_sup.htm#STread-suppressST"><B>*READ-SUPPRESS*</B></A>, which is slightly more explicit<P>
|
|
than the wording in #* itself.<P>
|
|
<P>
|
|
Also, this is safest for interchange with other dialects since it <P>
|
|
forces users not to rely on non-standard delimiters (like "2" in<P>
|
|
Test Case #1 below), and therefore it makes it more likely that<P>
|
|
when in a read-suppress context in another dialect, the tokenization<P>
|
|
a CL program has used will be the same as the tokenization such an<P>
|
|
`other dialect' expects. <P>
|
|
<P>
|
|
<B>Proposal (SHARP-STAR-DELIMITER:NOT-ZERO-OR-ONE):<P>
|
|
</B><P>
|
|
Specify that a bit vector is delimited by any character that <P>
|
|
is not a 0 or 1. Correct the description of <A REL=DEFINITION HREF="../Body/v_rd_sup.htm#STread-suppressST"><B>*READ-SUPPRESS*</B></A><P>
|
|
to indicate that #* stops reading and returns <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> as soon as<P>
|
|
any character other than 0 or 1.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This prefers a very literal reading of the wording in CLtL's description<P>
|
|
of #*, and reverses the behavior of *read-suppress* to be consistent.<P>
|
|
<P>
|
|
<B>Test Cases:<P>
|
|
</B><P>
|
|
These should signal an error under NORMAL-DELIMITER, and<P>
|
|
should return 3 under NOT-ZERO-OR-ONE:<P>
|
|
<P>
|
|
1. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#*012 3))<P>
|
|
2. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#*0123 4))<P>
|
|
<P>
|
|
These should return 1 under NORMAL-DELIMITER, and<P>
|
|
should return 2 under NOT-ZERO-OR-ONE:<P>
|
|
<P>
|
|
3. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#+NO-SUCH-FEATURE #*012 3))<P>
|
|
4. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#+NO-SUCH-FEATURE #*0123 4))<P>
|
|
<P>
|
|
These should signal an error under NORMAL-DELIMITER since<P>
|
|
# is not a terminating readmacro, and should return 2 under<P>
|
|
proposal NOT-ZERO-OR-ONE. (Note that in case 5 the two<P>
|
|
tokens are both bit-vectors under NOT-ZERO-OR-ONE, but in <P>
|
|
cases 6 and 7 the second token is a symbol.)<P>
|
|
<P>
|
|
5. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#*01#*01))<P>
|
|
6. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#*012#*012))<P>
|
|
7. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#*0123#*0123))<P>
|
|
<P>
|
|
These should return 0 under NORMAL-DELIMITER, and<P>
|
|
should return 1 under proposal NOT-ZERO-OR-ONE. (Note that<P>
|
|
in case 8 the token that is seen is a <A REL=DEFINITION HREF="../Body/t_bt_vec.htm#bit-vector"><B>bit-vector</B></A> under<P>
|
|
NOT-ZERO-OR-ONE, but in cases 9 and 10 it is a symbol.)<P>
|
|
<P>
|
|
8. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#+NO-SUCH-FEATURE #*01#*01))<P>
|
|
9. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#+NO-SUCH-FEATURE #*012#*012))<P>
|
|
10. (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>LENGTH</B></A> '(#+NO-SUCH-FEATURE #*0123#*0123))<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Symbolics Genera 8.1 implements NOT-ZERO-OR-ONE. <P>
|
|
<P>
|
|
Symbolics Cloe implements neither (being closer to the confusing<P>
|
|
thing that CLtL actually demands).<P>
|
|
<P>
|
|
Specific results:<P>
|
|
<P>
|
|
Cloe Genera<P>
|
|
<P>
|
|
#1 3 3<P>
|
|
#2 3 3<P>
|
|
#3 1 2<P>
|
|
#4 1 2<P>
|
|
#5 2 2<P>
|
|
#6 2 2<P>
|
|
#7 2 2<P>
|
|
#8 0 1<P>
|
|
#9 0 1<P>
|
|
#10 0 1<P>
|
|
<P>
|
|
Moon, commenting on the test cases for the previous version of this<P>
|
|
writeup, says MCL 2.0 is similar to Genera, but differs on one <P>
|
|
or two examples. [New sample data for this version not available.]<P>
|
|
<P>
|
|
JonL says Lucid has always supported NORMAL-DELIMITER.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
For implementations that are not already compatible, the cost is <P>
|
|
probably relatively small.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Problem situations could be mechanically detected, and semi-automatically<P>
|
|
corrected in a straightforward way.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Implementations could differ on how #* expressions were parsed,<P>
|
|
causing portability problems.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Cost of non-adoption is avoided.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
The effect of NOT-ZERO-OR-ONE, while seemingly what CLtL intends,<P>
|
|
is often suprising (i.e., unintuitive) to new users.<P>
|
|
The NORMAL-DELIMITER is probably more aesthetic since it uses <P>
|
|
conventional rules for delimiters.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Moon, Barmar, and Pitman support NORMAL-DELIMITER.<P>
|
|
<P>
|
|
Moon says ``if we vote for NOT-ZERO-OR-ONE then I think we're<P>
|
|
inconsistent if we don't say that (length '(#o12399)) is 2.''<P>
|
|
Barmar disagrees that this particular consistency is in issue.<P>
|
|
Moon cited another test case of #o2+2.<P>
|
|
JonL noted that Lucid barfs not only on #o2+2 but even on #o12399.<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>
|