296 lines
24 KiB
HTML
296 lines
24 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 DATA-IO 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/iss088_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss089.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss090_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/iss088_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss089.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss090_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue DATA-IO Writeup</H2>
|
|
|
|
<PRE>This is a new issue. It arose from an investigation of features<P>
|
|
that are plausibly needed but missing from draft ANSI Common Lisp.<P>
|
|
This issue seems sufficiently simple and noncontroversial that<P>
|
|
I would like to see it on the agenda for the June X3J13 meeting.<P>
|
|
<P>
|
|
This issue has been amended based on last minute discussion. Clarify<P>
|
|
that "readable" is defined in terms of "similar as constants" as<P>
|
|
defined in issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A>. This modifies point 1a and<P>
|
|
adds new points 1d, 1e, and 1f. The interaction between <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A><P>
|
|
and other printer control variables has been tightened; this modifies<P>
|
|
point 1c and deletes the old points 1d and 1e.<P>
|
|
<P>
|
|
<B>Issue:</B> <A HREF="iss089.htm">DATA-IO</A><P>
|
|
<B>References:</B> CLtL pp.360, 370, 382<P>
|
|
Related issues: <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A><P>
|
|
<B>Category:</B> ADDITION<P>
|
|
<B>Edit history:</B> Version 1, 9-May-89, by Moon<P>
|
|
Version 2, 10-May-89, by Moon<P>
|
|
(clarify ambiguities, add <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A>)<P>
|
|
Version 3, 18-May-89, by Moon (respond to KMP's comments)<P>
|
|
Version 4, 21-May-89, by Moon (almost-final cleanup)<P>
|
|
Version 5, 22-May-89, by Pitman (``never say never'')<P>
|
|
Version 6, 23-May-89, by Moon (final cleanup)<P>
|
|
Version 7, 18-Jun-89, by Moon (more fixes based on<P>
|
|
discussion in the cleanup subcommittee)<P>
|
|
Version 8, 23-Jun-89, by Moon (fixes based on discussion)<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
Storing data in textual form in files, as Lisp expressions, is common<P>
|
|
practice but has some pitfalls. Files can be unreadable if #<...> syntax<P>
|
|
is written by the printer, or if the reader syntax or package varies<P>
|
|
between writing and reading. Files of data intended to be carried from<P>
|
|
one Lisp implementation to another can fail to read correctly if<P>
|
|
implementation-dependent syntax extensions get used when not intended.<P>
|
|
<P>
|
|
CLtL p.370 recommends that unreadable objects be printed with #<...><P>
|
|
syntax including implementation-dependent information. Now that users<P>
|
|
can write their own <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A> methods, a way is needed for such<P>
|
|
methods to print this syntax without any implementation-dependent coding.<P>
|
|
<P>
|
|
<B>Proposal (DATA-IO:ADD-SUPPORT):<P>
|
|
</B><P>
|
|
1a. Add a new variable <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A>. Add a corresponding keyword<P>
|
|
argument :READABLY to <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A>. The default value of <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is<P>
|
|
<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. If <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true, then printing any object produces a<P>
|
|
printed representation that the reader will accept. The reader will<P>
|
|
produce an object that is "similar as a constant" to the object that<P>
|
|
was printed. The term "similar as a constant" is defined in the<P>
|
|
already accepted compiler issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES:SPECIFY</A>.<P>
|
|
<P>
|
|
If <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true and printing a readable printed<P>
|
|
representation is not possible, the printer signals an error of type<P>
|
|
<A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A> rather than using an unreadable syntax such as #<...>.<P>
|
|
The printed representation produced when <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true might<P>
|
|
or might not be the same as the printed representation produced when<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is false.<P>
|
|
<P>
|
|
1b. All methods for <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A> must obey <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A>. This<P>
|
|
includes both user-defined methods and implementation-defined methods.<P>
|
|
<P>
|
|
1c. If <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true and another printer control variable<P>
|
|
(<A REL=DEFINITION HREF="../Body/v_pr_lev.htm#STprint-lengthST"><B>*PRINT-LENGTH*</B></A>, <A REL=DEFINITION HREF="../Body/v_pr_lev.htm#STprint-levelST"><B>*PRINT-LEVEL*</B></A>, <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A>, <A REL=DEFINITION HREF="../Body/v_pr_gen.htm#STprint-gensymST"><B>*PRINT-GENSYM*</B></A>,<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_ar.htm#STprint-arrayST"><B>*PRINT-ARRAY*</B></A>, <A REL=DEFINITION HREF="../Body/a_or.htm#or"><B>or</B></A> an implementation-defined printer control <A REL=DEFINITION HREF="../Body/f_docume.htm#variable"><B>variable</B></A>)<P>
|
|
would cause the requirements of point 1a to be violated, that other<P>
|
|
printer control variable is ignored.<P>
|
|
<P>
|
|
1d. The printing of interned symbols is not affected by <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A>,<P>
|
|
regardless of the outcome of issue <A HREF="iss063.htm">COMPILE-FILE-SYMBOL-HANDLING</A><P>
|
|
(referenced by issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A>).<P>
|
|
<P>
|
|
1e. Note that the "similar as a constant" rule for readable printing<P>
|
|
implies that #A or #( syntax cannot be used for arrays of element-type<P>
|
|
other than T. An implementation will have to use another syntax or<P>
|
|
signal a <A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A> error. A <A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A> error will not<P>
|
|
be signalled for strings or bit-vectors.<P>
|
|
<P>
|
|
1f. Readable printing of structures and standard-objects is controlled<P>
|
|
by their <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A>, not by their <A REL=DEFINITION HREF="../Body/f_mk_ld_.htm#make-load-form"><B>MAKE-LOAD-FORM</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A>.<P>
|
|
"Similarity as a constant" for these objects is application dependent<P>
|
|
and hence is defined to be whatever these methods do.<P>
|
|
<P>
|
|
2. Add a new reader control variable, <A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A>, whose default value is<P>
|
|
T. If <A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A> is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, the #. reader macro signals an error. If<P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A> is false and <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true, any <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> that would output a #. reader macro either outputs something<P>
|
|
different or signals an error of type <A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A>.<P>
|
|
<P>
|
|
3. Add a new macro:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> &body body [Macro]<P>
|
|
<P>
|
|
Within the dynamic extent of <body>, all reader/printer control<P>
|
|
variables, including any implementation-defined ones not specified by<P>
|
|
Common Lisp, are bound to values that produce <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> read/print<P>
|
|
behavior. The values for Common Lisp specified variables are:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pkg.htm#STpackageST"><B>*PACKAGE*</B></A> The USER package<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_ar.htm#STprint-arrayST"><B>*PRINT-ARRAY*</B></A> T<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_bas.htm#STprint-baseST"><B>*PRINT-BASE*</B></A> 10<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> :UPCASE<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_cir.htm#STprint-circleST"><B>*PRINT-CIRCLE*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> T<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_gen.htm#STprint-gensymST"><B>*PRINT-GENSYM*</B></A> T<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_lev.htm#STprint-lengthST"><B>*PRINT-LENGTH*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_lev.htm#STprint-levelST"><B>*PRINT-LEVEL*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_pre.htm#STprint-prettyST"><B>*PRINT-PRETTY*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_bas.htm#STprint-radixST"><B>*PRINT-RADIX*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> T<P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_bas.htm#STread-baseST"><B>*READ-BASE*</B></A> 10<P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_def.htm#STread-default-float-formatST"><B>*READ-DEFAULT-FLOAT-FORMAT*</B></A> <A REL=DEFINITION HREF="../Body/t_short_.htm#single-float"><B>SINGLE-FLOAT</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A> T<P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_sup.htm#STread-suppressST"><B>*READ-SUPPRESS*</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> 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>
|
|
The values returned by <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> are the values<P>
|
|
of the last body form, or <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if there are no body forms.<P>
|
|
<P>
|
|
4. Add a new macro:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> (object stream &key type identity) [Macro]<P>
|
|
&body body<P>
|
|
<P>
|
|
Output a printed representation of <object> on <stream>, beginning with<P>
|
|
"#<" and ending with ">". Everything output to <stream> by the <body><P>
|
|
forms is enclosed in the angle brackets. If :type is true, the body<P>
|
|
output is preceded by a brief description of the object's type and a<P>
|
|
space character. If :identity is true, the body output is followed by<P>
|
|
a space character and a representation of the object's identity,<P>
|
|
typically a storage address.<P>
|
|
<P>
|
|
If <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true, <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> signals an error<P>
|
|
of type <A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A> without printing anything.<P>
|
|
<P>
|
|
The <object>, <stream>, :type, and :identity arguments are all evaluated<P>
|
|
normally. :type and :identity default to false. It is valid to omit<P>
|
|
the <body> forms. If :type and :identity are both true and there are no<P>
|
|
<body> forms, only one space character separates the type and the identity.<P>
|
|
<P>
|
|
The value returned by <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>.<P>
|
|
<P>
|
|
5. Add a new condition type:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/e_pr_not.htm#print-not-readable"><B>PRINT-NOT-READABLE</B></A> [Type]<P>
|
|
<P>
|
|
Errors which occur during output while <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is true, as a<P>
|
|
result of attempting to output a printed representation that cannot be<P>
|
|
read back, should inherit from this type. This is a subtype of <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A>.<P>
|
|
The init keyword :OBJECT is supported to initialize the slot containing<P>
|
|
the object being printed, which can be accessed using<P>
|
|
<A REL=DEFINITION HREF="../Body/f_pr_not.htm#print-not-readable-object"><B>PRINT-NOT-READABLE-OBJECT</B></A>.<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
;; Example #1: Reliable Write-Read<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_w_open.htm#with-open-file"><B>WITH-OPEN-FILE</B></A> (FILE <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> :DIRECTION :OUTPUT)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A><P>
|
|
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A> DATA FILE)))<P>
|
|
<P>
|
|
; ... Later, in another Lisp:<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_w_open.htm#with-open-file"><B>WITH-OPEN-FILE</B></A> (FILE <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> :DIRECTION :INPUT)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A><P>
|
|
(<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>SETQ</B></A> DATA (<A REL=DEFINITION HREF="../Body/f_rd_rd.htm#read"><B>READ</B></A> FILE))))<P>
|
|
<P>
|
|
;; Example #2: Use of <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A><P>
|
|
;; Note that in this example, the precise form of the output<P>
|
|
;; is really implementation-dependent.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmet.htm#defmethod"><B>DEFMETHOD</B></A> <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A> ((OBJ AIRPLANE) <A REL=DEFINITION HREF="../Body/t_stream.htm#stream"><B>STREAM</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> (OBJ <A REL=DEFINITION HREF="../Body/t_stream.htm#stream"><B>STREAM</B></A> :TYPE T :IDENTITY T)<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#princ"><B>PRINC</B></A> (TAIL-NUMBER OBJ) <A REL=DEFINITION HREF="../Body/t_stream.htm#stream"><B>STREAM</B></A>)))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A> MY-AIRPLANE)<P>
|
|
#<Airplane NW0773 36000123135> ;in Implementation A<P>
|
|
;or<P>
|
|
#<FAA:AIRPLANE NW0773 17> ;in Implementation B<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
1. <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is important so that errors involving data with no<P>
|
|
readable printed representation are detected when writing the file, not<P>
|
|
later on when the file is read.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> is different from <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> because output printed<P>
|
|
with escapes only has to be generally recognizable by humans, whereas<P>
|
|
output printed readably has to be reliably recognizable by computers.<P>
|
|
<P>
|
|
2. Binding <A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A> to <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> is useful when reading data that came from<P>
|
|
an untrusted source, such as a network or a user-supplied data file, to<P>
|
|
prevent the #. reader macro from being exploited as a "Trojan horse" to<P>
|
|
cause arbitrary forms to be evaluated.<P>
|
|
<P>
|
|
3. Providing the <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> macro to bind all the variables,<P>
|
|
instead of using <A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> and explicit bindings of the existing variables,<P>
|
|
ensures that nothing is overlooked and avoids problems with<P>
|
|
implementation-defined reader/printer control variables.<P>
|
|
<P>
|
|
If the user wishes to use a non-standard value for some variable, such as<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pkg.htm#STpackageST"><B>*PACKAGE*</B></A> or <A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A>, it can be bound by <A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> inside the body of<P>
|
|
<A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A>. Similarly, if the user dislikes the somewhat<P>
|
|
arbitrary choices of values for <A REL=DEFINITION HREF="../Body/v_pr_cir.htm#STprint-circleST"><B>*PRINT-CIRCLE*</B></A> and <A REL=DEFINITION HREF="../Body/v_pr_pre.htm#STprint-prettyST"><B>*PRINT-PRETTY*</B></A>, they<P>
|
|
can be bound to the preferred values inside the body.<P>
|
|
<P>
|
|
4. <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> allows user-written PRINT-OBEJCT methods to<P>
|
|
adhere to implementation-specific style without requiring users to write<P>
|
|
implementation-dependent code.<P>
|
|
<P>
|
|
5. Defining a specific condition type associated with <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A><P>
|
|
makes it possible for programs to handle the condition and recognize<P>
|
|
the offending object.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Symbolics Genera has had these features for many years, except with<P>
|
|
different names. For instance, <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> is named<P>
|
|
WITH-STANDARD-IO-ENVIRONMENT and binds <A REL=DEFINITION HREF="../Body/v_pkg.htm#STpackageST"><B>*PACKAGE*</B></A> to a non-standard<P>
|
|
package. The proposed new names are better than the Genera names.<P>
|
|
<P>
|
|
Genera's WITH-STANDARD-IO-ENVIRONMENT also disables #., to prevent trojan<P>
|
|
horses, since #. could evaluate an arbitrary form. This is particularly<P>
|
|
important for network protocols. <A REL=DEFINITION HREF="../Body/m_w_std_.htm#with-standard-io-syntax"><B>WITH-STANDARD-IO-SYNTAX</B></A> does not bind<P>
|
|
<A REL=DEFINITION HREF="../Body/v_rd_eva.htm#STread-evalST"><B>*READ-EVAL*</B></A> to <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, because that would prevent using #. in the printer<P>
|
|
for common datatypes, which is current practice in some implementations<P>
|
|
for printing PATHNAMEs or RANDOM-STATEs.<P>
|
|
<P>
|
|
In Genera, <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> is called SYS:PRINTING-RANDOM-OBJECT<P>
|
|
and takes slightly different arguments. In PCL, <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A><P>
|
|
is called PCL:PRINTING-RANDOM-THING.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Very small, these features are all easy to add. If #. is output by any<P>
|
|
system-supplied print methods, they might want to invent a different<P>
|
|
syntax, however that is not required by this proposal.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
None if they don't use the feature. Otherwise just the cost of<P>
|
|
supporting <A REL=DEFINITION HREF="../Body/v_pr_rda.htm#STprint-readablyST"><B>*PRINT-READABLY*</B></A> or using <A REL=DEFINITION HREF="../Body/m_pr_unr.htm#print-unreadable-object"><B>PRINT-UNREADABLE-OBJECT</B></A> in their<P>
|
|
<A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A> methods.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
There will be no reliable, <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> way to write data into a file.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
Negligible. Entering <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A> may be slightly slower since there is<P>
|
|
one more keyword argument to parse and one more special variable<P>
|
|
to bind before calling <A REL=DEFINITION HREF="../Body/f_pr_obj.htm#print-object"><B>PRINT-OBJECT</B></A>.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Data can be written into files reliably without resorting to<P>
|
|
implementation-specific programming.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
Mildly improved.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Pitman and Moon support this proposal.<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>
|