178 lines
11 KiB
HTML
178 lines
11 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 FORMAT-STRING-ARGUMENTS 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/iss169_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss170.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss171_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/iss169_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss170.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss171_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue FORMAT-STRING-ARGUMENTS Writeup</H2>
|
||
|
|
||
|
<PRE><B>Issue:</B> <A HREF="iss170.htm">FORMAT-STRING-ARGUMENTS</A><P>
|
||
|
<B>References:</B> <P>
|
||
|
Related issues: Issue <A HREF="iss270.htm">PRETTY-PRINT-INTERFACE</A><P>
|
||
|
<B>Category:</B> CLARIFICATION, CHANGE<P>
|
||
|
<B>Edit history:</B> V1, 10 May 90, Sandra Loosemore<P>
|
||
|
<P>
|
||
|
<B>Problem description:<P>
|
||
|
</B><P>
|
||
|
Issue <A HREF="iss270.htm">PRETTY-PRINT-INTERFACE</A> says that<P>
|
||
|
The function <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> is extended so that it can accept a<P>
|
||
|
function instead of a <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> string. (This change is also made<P>
|
||
|
in the other functions that accept <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> strings such as <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A><P>
|
||
|
and <A REL=DEFINITION HREF="../Body/f_warn.htm#warn"><B>WARN</B></A>.)<P>
|
||
|
<P>
|
||
|
The pretty printer proposal did not explicitly address whether<P>
|
||
|
this also affects the :FORMAT-STRING slot of <A REL=DEFINITION HREF="../Body/e_smp_cn.htm#simple-condition"><B>simple-condition</B></A> <P>
|
||
|
objects, and whether any macros (as well as functions) specified <P>
|
||
|
in the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> were affected by the change.<P>
|
||
|
<P>
|
||
|
Also, there is potential for confusion in using the terminology<P>
|
||
|
"format strings" to refer to objects that are now permitted to<P>
|
||
|
be either strings or functions.<P>
|
||
|
<P>
|
||
|
There are two proposals, SPECIFY and RETRACT.<P>
|
||
|
<P>
|
||
|
This is issue #1 from Loosemore's list.<P>
|
||
|
<P>
|
||
|
<B>Proposal (FORMAT-STRING-ARGUMENTS:SPECIFY):<P>
|
||
|
</B><P>
|
||
|
(1) Clarify that the following functions and macros which formerly were<P>
|
||
|
specified to take format strings as arguments now accept either<P>
|
||
|
a format string or a format function:<P>
|
||
|
<P>
|
||
|
<A REL=DEFINITION HREF="../Body/m_assert.htm#assert"><B>ASSERT</B></A> (datum; treated like a string argument is now)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_break.htm#break"><B>BREAK</B></A> (format-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_cerror.htm#cerror"><B>CERROR</B></A> (both continue-format-string and datum arguments)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/m_defi_4.htm#define-method-combination"><B>DEFINE-METHOD-COMBINATION</B></A> (:DESCRIPTION argument)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> (datum; treated like a string argument is now)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> (control-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_invali.htm#invalid-method-error"><B>INVALID-METHOD-ERROR</B></A> (format-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_meth_1.htm#method-combination-error"><B>METHOD-COMBINATION-ERROR</B></A> (format-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_signal.htm#signal"><B>SIGNAL</B></A> (datum; treated like a string argument is now)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_warn.htm#warn"><B>WARN</B></A> (datum; treated like a string argument is now)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/m_w_smp_.htm#with-simple-restart"><B>WITH-SIMPLE-RESTART</B></A> (format-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_y_or_n.htm#y-or-n-p"><B>Y-OR-N-P</B></A> (format-string)<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_y_or_n.htm#yes-or-no-p"><B>YES-OR-NO-P</B></A> (format-string)<P>
|
||
|
<P>
|
||
|
(2) Clarify that the :FORMAT-STRING argument passed to <A REL=DEFINITION HREF="../Body/f_mk_cnd.htm#make-condition"><B>MAKE-CONDITION</B></A><P>
|
||
|
to construct a condition which is a subtype of <A REL=DEFINITION HREF="../Body/e_smp_cn.htm#simple-condition"><B>SIMPLE-CONDITION</B></A><P>
|
||
|
may be either a string or a function, and the accessor <P>
|
||
|
SIMPLE-CONDITION-FORMAT-STRING can return either a string or a function.<P>
|
||
|
<P>
|
||
|
(3) Change the name of the :FORMAT-STRING argument to <A REL=DEFINITION HREF="../Body/f_mk_cnd.htm#make-condition"><B>MAKE-CONDITION</B></A> <P>
|
||
|
associated with <A REL=DEFINITION HREF="../Body/e_smp_cn.htm#simple-condition"><B>SIMPLE-CONDITION</B></A> types to :FORMAT-CONTROL, and<P>
|
||
|
rename the accessor function to <A REL=DEFINITION HREF="../Body/f_smp_cn.htm#simple-condition-format-control"><B>SIMPLE-CONDITION-FORMAT-CONTROL</B></A>. As<P>
|
||
|
an editorial matter, change all references to arguments now<P>
|
||
|
named "format-string" to "format-control".<P>
|
||
|
<P>
|
||
|
Rationale for proposal SPECIFY:<P>
|
||
|
<P>
|
||
|
Items (1) and (2) were probably what was intended by the<P>
|
||
|
<A HREF="iss270.htm">PRETTY-PRINT-INTERFACE</A> proposal. Item (3) is a logical<P>
|
||
|
extension; since the arguments need not be strings, calling<P>
|
||
|
them "format-strings" is a misnomer.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Proposal (FORMAT-STRING-ARGUMENTS:RETRACT):<P>
|
||
|
</B><P>
|
||
|
(1) Retract the part of issue <A HREF="iss270.htm">PRETTY-PRINT-INTERFACE</A> that required<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A>, related functions such as <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> and <A REL=DEFINITION HREF="../Body/f_warn.htm#warn"><B>WARN</B></A>, and the ~?<P>
|
||
|
and ~{~} directives to accept format control functions as well<P>
|
||
|
as strings.<P>
|
||
|
<P>
|
||
|
(2) Remove the <A REL=DEFINITION HREF="../Body/m_format.htm#formatter"><B>FORMATTER</B></A> macro from the language.<P>
|
||
|
<P>
|
||
|
Rationale for proposal RETRACT:<P>
|
||
|
<P>
|
||
|
It is easier to remove this feature than to try to fix the rest<P>
|
||
|
of the language to be consistent with it. Having a macro to<P>
|
||
|
"compile" format strings into functions is probably not useful<P>
|
||
|
in the absence of the extensions to <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A>.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Current Practice:<P>
|
||
|
</B><P>
|
||
|
Unknown. The pretty printer specification is a fairly recent<P>
|
||
|
addition to the language and it probably hasn't been fully<P>
|
||
|
integrated into any implementation yet.<P>
|
||
|
<P>
|
||
|
<B>Cost to Implementors:<P>
|
||
|
</B><P>
|
||
|
The actual implementation cost of extending the listed functions <P>
|
||
|
and macros to accept function arguments is probably small, since<P>
|
||
|
in most cases they just pass the argument to <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> anyway.<P>
|
||
|
Both proposals probably involve changes to documentation.<P>
|
||
|
<P>
|
||
|
<B>Cost to Users:<P>
|
||
|
</B><P>
|
||
|
For proposal SPECIFY, the incompatible change to the name of the <P>
|
||
|
:FORMAT-STRING slot of <A REL=DEFINITION HREF="../Body/e_smp_cn.htm#simple-condition"><B>SIMPLE-CONDITION</B></A> objects may cause some <P>
|
||
|
problems for users who have started using the condition system<P>
|
||
|
in their code, but these ought to be fairly straightforward to <P>
|
||
|
track down and fix.<P>
|
||
|
<P>
|
||
|
Proposal RETRACT may cause some problems for users who have<P>
|
||
|
started writing code which uses the <A REL=DEFINITION HREF="../Body/m_format.htm#formatter"><B>FORMATTER</B></A> macro and the<P>
|
||
|
extension to <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> to accept functions, but again the<P>
|
||
|
problems should generally be easy to find and fix.<P>
|
||
|
<P>
|
||
|
<B>Cost of non-adoption:<P>
|
||
|
</B><P>
|
||
|
Parts of the language are poorly specified.<P>
|
||
|
<P>
|
||
|
<B>Performance impact:<P>
|
||
|
</B><P>
|
||
|
The ability to "compile" format strings into functions in advance can<P>
|
||
|
potentially lead to greater runtime efficiency. On the other<P>
|
||
|
hand, some implementations might implement <A REL=DEFINITION HREF="../Body/m_format.htm#formatter"><B>FORMATTER</B></A> in such a<P>
|
||
|
way that it is less efficient than passing a format string<P>
|
||
|
directly. Furthermore, even without <A REL=DEFINITION HREF="../Body/m_format.htm#formatter"><B>FORMATTER</B></A> in the language,<P>
|
||
|
it is still possible for implementations to do a compile-time<P>
|
||
|
transformation to "compile" constant string arguments to <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A><P>
|
||
|
and related functions.<P>
|
||
|
<P>
|
||
|
<B>Benefits:<P>
|
||
|
</B><P>
|
||
|
The language is better specified.<P>
|
||
|
<P>
|
||
|
<B>Esthetics:<P>
|
||
|
</B><P>
|
||
|
Either proposal would be an improvement over the current<P>
|
||
|
situation.<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
Conceivably, the <A REL=DEFINITION HREF="../Body/m_format.htm#formatter"><B>FORMATTER</B></A> macro could be left in the language<P>
|
||
|
even while removing the extensions to <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> and friends, but it's <P>
|
||
|
not clear how useful this would be to users.<P>
|
||
|
<P>
|
||
|
Loosemore opposes other partial solutions (like requiring <A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> <P>
|
||
|
to accept both strings and functions but specifying everything else <P>
|
||
|
to accept only strings) on the grounds that they would<P>
|
||
|
introduce additional, unnecessary complexity and inconsistency<P>
|
||
|
into the language. If the feeling is that this feature belongs<P>
|
||
|
in the language, we ought to bite the bullet and do it<P>
|
||
|
properly.<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>
|