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

139 lines
10 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 WITH-STANDARD-IO-SYNTAX-READTABLE 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/iss364_w.htm">
<LINK REL=UP HREF="../Issues/iss365.htm">
<LINK REL=NEXT HREF="../Issues/I_Categ.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/iss364_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss365.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/I_Categ.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue WITH-STANDARD-IO-SYNTAX-READTABLE Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss365.htm">WITH-STANDARD-IO-SYNTAX-READTABLE</A><P>
<B>References:</B> CLtL2 pp.565-6<P>
Related issues: <A HREF="iss089.htm">DATA-IO</A><P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit history:</B> Version 1, 29-Nov-90, by Haflich<P>
Version 2, 08-Apr-90, by Pitman <P>
(add newly worded proposal from meeting)<P>
<B>Status:</B> X3J13 passed option X3J13-MAR-91 on vote of 11-1, March 1991.<P>
<P>
<B>Problem description:<P>
</B><P>
Proposal <A HREF="iss089.htm">DATA-IO:ADD-SUPPORT</A> passed in June 89 added the new macro<P>
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> which executes a body with all the read/print<P>
special variables bound to known values. All the prescribed binding<P>
values are immutable objects except for <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A>, which is required<P>
to be bound to &quot;the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>.&quot;<P>
<P>
Not addressed was the question what happens if someone modifies the<P>
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> inside the body, or captures the value and modifies it<P>
later.<P>
<P>
If &quot;the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> readtable&quot; were the implementation's special copy of<P>
the initial <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>, modifying this <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> would have the<P>
unfortunate effect of breaking the defined behaviour of <A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A><P>
as a way of obtaining a fresh copy of the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>.<P>
<P>
If &quot;the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> readtable&quot; provided by the macroexpansion were a<P>
single reusable copy of the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>, <A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A> would<P>
be safe, but the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> seen successive calls to expansions of the<P>
macro would not necessarily be the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>.<P>
<P>
If &quot;the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> readtable&quot; were a fresh copy of the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A><P>
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> obtained from <A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A>, there would be no surprises,<P>
but the cost of consing readtables would be a disincentive to using<P>
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> where performance was important.<P>
<P>
Other implementation strategies could be considered -- for example, a<P>
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> could record whether they have ever been modified, and entry<P>
to <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> would create a fresh copy only if the<P>
previously copy had been modified. But even this wouldn't be safe if<P>
someone captured the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> and modified it later after the<P>
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> had been reused for a later execution of a<P>
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> expansion.<P>
<P>
<B>Proposal (WITH-STANDARD-IO-SYNTAX-READTABLE:X3J13-MAR-91):<P>
</B><P>
Specify that results are undefined if the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> is modified.<P>
<P>
Clarify that the `<A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>' (the one copied by <A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A><P>
when it is given a <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> argument, or the one to which <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> is bound<P>
by <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A>) must not be the same as the `initial <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>'<P>
(the one to which <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> is initially bound when Lisp starts).<P>
<P>
<B>Proposal (WITH-STANDARD-IO-SYNTAX-READTABLE:DISALLOW-MODIFICATION):<P>
</B><P>
Specify that results are undefined if the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> object provided by<P>
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> is modified.<P>
<P>
<B>Rationale:<P>
</B><P>
This is ackowledgement of the status quo and makes explicit a<P>
limitation of <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> which would not otherwise<P>
be obvious to users.<P>
<P>
<B>Current practice:<P>
</B><P>
It's unclear anyone actually implements <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A>.<P>
It's even more unclear anyone actually uses it.<P>
It's highly unlikely anyone has ever yet written code that modifies<P>
a <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> inside the body.<P>
<P>
Does Genera's WITH-STANDARD-IO-ENVIRONMENT deal with this issue?<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
If ALLOW is adopted there will be some annoying changes required to<P>
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> implementation and <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> modifying functions if<P>
implementors want to avoid ther overhead of copying a new <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> at<P>
every entry to a <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> expansion.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None, assuming no user has yet violated the restriction. User code<P>
that needs to modify a <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> is free to make an explicit copy,<P>
but no other code needs pay the price.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
This is only a clarification. Modifying the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> inside<P>
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> will continue to have undetermined effects<P>
anyway.<P>
<P>
<B>Performance impact:<P>
</B><P>
None.<P>
<P>
<B>Benefits:<P>
</B><P>
Another X3J13-introduced crack in the language is caulked.<P>
<P>
<B>Esthetics:<P>
</B><P>
Bill Ackerman told me some twenty years ago: &quot;Lisp would be the<P>
perfect computer language, except that it has IO.&quot;<P>
<P>
<B>Discussion:<P>
</B><P>
Haflich recommends adoption.<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>