125 lines
7.9 KiB
HTML
125 lines
7.9 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 STRING-COERCION 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/iss328_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss329.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss330_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/iss328_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss329.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss330_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue STRING-COERCION Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss329.htm">STRING-COERCION</A><P>
|
|
<B>References:</B> Strings (pp299-304),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringEQ"><B>STRING=</B></A> (p300), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-equal"><B>STRING-EQUAL</B></A> (p301), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringLT"><B>STRING<</B></A> (p301),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringGT"><B>STRING></B></A> (p301), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringLTEQ"><B>STRING<=</B></A> (p301), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringGTEQ"><B>STRING>=</B></A> (p301),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringSLEQ"><B>STRING/=</B></A> (p301), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-lessp"><B>STRING-LESSP</B></A> (p302), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-greaterp"><B>STRING-GREATERP</B></A> (p302),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-not-greaterp"><B>STRING-NOT-GREATERP</B></A> (p302), <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-not-lessp"><B>STRING-NOT-LESSP</B></A> (p302),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-not-equal"><B>STRING-NOT-EQUAL</B></A> (p302), <A REL=DEFINITION HREF="../Body/f_stg_tr.htm#string-trim"><B>STRING-TRIM</B></A> (p302), <A REL=DEFINITION HREF="../Body/f_stg_tr.htm#string-left-trim"><B>STRING-LEFT-TRIM</B></A> (p302),<P>
|
|
<A REL=DEFINITION HREF="../Body/f_stg_tr.htm#string-right-trim"><B>STRING-RIGHT-TRIM</B></A> (p302), <A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>STRING-UPCASE</B></A> (p303), <A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-downcase"><B>STRING-DOWNCASE</B></A> (p303),<P>
|
|
and <A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-capitalize"><B>STRING-CAPITALIZE</B></A> (p303).<P>
|
|
Related issues: none<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit history:</B> Version 1, 9-May-89 by Moon<P>
|
|
Version 2, 9-May-89 by Pitman (editorial changes)<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
CLtL is inconsistent about the argument coercion performed by the<P>
|
|
referenced functions. Page 299 says that the <string> argument can<P>
|
|
be either a symbol or a string. Page 304 says that these functions<P>
|
|
effectively call the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function, thus accepting a symbol,<P>
|
|
a string, or a character.<P>
|
|
<P>
|
|
Neither page lists the set of affected functions explicitly.<P>
|
|
<P>
|
|
Page 304 says that if any other data type is used, an error is<P>
|
|
signalled. But some implementations allow other types, such as<P>
|
|
pathnames, to be coerced to strings, which page 299 appears to allow<P>
|
|
but page 304 appears to forbid. In some implementations these<P>
|
|
coercions are under user control via methods for a generic function.<P>
|
|
<P>
|
|
<B>Proposal (STRING-COERCION:MAKE-CONSISTENT):<P>
|
|
</B><P>
|
|
Specify that the referenced functions perform coercion identical to<P>
|
|
the action of the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function.<P>
|
|
<P>
|
|
Specify that the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function can perform additional implementation<P>
|
|
dependent coercions. In all cases the returned value is of type <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A>.<P>
|
|
Only in the case where no coercion is defined is the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function<P>
|
|
required to signal an error; in that case, the error is of type <A REL=DEFINITION HREF="../Body/e_tp_err.htm#type-error"><B>TYPE-ERROR</B></A>.<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/f_stgeq_.htm#string-lessp"><B>string-lessp</B></A> #\a "B") => T<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Our choices are to make the coercion identical to the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function,<P>
|
|
identical to the <A REL=DEFINITION HREF="../Body/f_coerce.htm#coerce"><B>COERCE</B></A> function, or different from both of them. The<P>
|
|
<A REL=DEFINITION HREF="../Body/f_coerce.htm#coerce"><B>COERCE</B></A> function won't coerce non-null symbols to strings, so it is out.<P>
|
|
Being consistent with the <A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function seems better than inventing<P>
|
|
yet another set of string coercion rules. Removing the ability for the<P>
|
|
<A REL=DEFINITION HREF="../Body/a_string.htm#string"><B>STRING</B></A> function to coerce characters to strings would be an incompatible<P>
|
|
change, so instead we clarify that the other functions have that ability.<P>
|
|
<P>
|
|
Allowing additional coercions is harmless and consistent with current<P>
|
|
practice.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Symbolics Genera follows page 304 except for allowing additional<P>
|
|
coercions. Symbolics Cloe follows page 299 except for not allowing<P>
|
|
additional coercions.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Small changes to eighteen functions.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
None, this is upward-compatible.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
Inconsistency and confusion about what coercions are allowed.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
None. If these things have to accept symbols, accepting characters<P>
|
|
too can't make much difference. The implementation of character<P>
|
|
arguments to string functions might cons a string, but this has no<P>
|
|
performance impact on programs that don't use the feature.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Consistency.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
Consistency.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
None.<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>
|