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

157 lines
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 PATHNAME-PRINT-READ 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/iss259_w.htm">
<LINK REL=UP HREF="../Issues/iss260.htm">
<LINK REL=NEXT HREF="../Issues/iss261_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/iss259_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss260.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss261_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue PATHNAME-PRINT-READ Writeup</H2>
<PRE><B>Status:</B> Passed, as amended, Jun89 X3J13<P>
<P>
<B>Issue:</B> <A HREF="iss260.htm">PATHNAME-PRINT-READ</A><P>
<B>References:</B> File System Interface (pp409-427)<P>
<B>Category:</B> CHANGE/ADDITION<P>
<B>Edit history:</B> 21-Oct-88, Version 1 by Pitman<P>
3-Jul-89, Version 2 by Masinter<P>
<P>
<B>Problem Description:<P>
</B><P>
Although pathnames are required to print re-readably, there is no<P>
standardized representation for pathnames and so no standardized<P>
way in which they should print.<P>
<P>
Further, it is common in programs to want pathnames to print in<P>
their file-system specific format.<P>
<P>
<B>Proposal (PATHNAME-PRINT-READ:SHARPSIGN-P):<P>
</B><P>
Define the reader syntax #P&quot;...&quot; to be equivalent to <P>
#.(<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;...&quot;).<P>
<P>
Define that when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> is true, the syntax #P&quot;...&quot; is<P>
how a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> should be printed by <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A> (and hence by <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A>, etc.). The &quot;...&quot; is the <A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>namestring</B></A> representation of the<P>
<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A>.<P>
<P>
Define that when <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#write"><B>WRITE</B></A> writes a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A><P>
object P by writing (<A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A> p) instead.<P>
<P>
<B>Test Case:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;foo.lisp&quot;)<P>
=&gt; #P&quot;foo.lisp&quot;<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>FORMAT</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> &quot;Written to ~A.&quot; #P&quot;foo.bin&quot;)<P>
=&gt; &quot;Written to foo.bin.&quot;<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> #P&quot;foo.bin&quot; '<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A>)<P>
=&gt; T<P>
<P>
<B>Rationale:<P>
</B><P>
This satisfies the stated goals.<P>
<P>
[For :ESCAPE T] It will not be possible to make the printed<P>
<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> printed representation totally portable because of<P>
variations in file systems, but for different Common Lisp<P>
implementations on the same file system, or for Common Lisp<P>
systems running on file systems having compatible syntax,<P>
portability would be improved by this specification.<P>
<P>
Also, some implementations (eg, Symbolics Genera) use<P>
specialized representations for pathnames on different file<P>
systems. Eg, an MSDOS <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> is of type MSDOS-PATHNAME,<P>
not just type <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A>. #S(<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> ...) is not only more<P>
verbose than necessary but might be misleading to some users<P>
because the object created will not have a <A REL=DEFINITION HREF="../Body/f_tp_of.htm#type-of"><B>TYPE-OF</B></A> <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A>.<P>
<P>
[For :ESCAPE NIL] Printing the <A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>namestring</B></A> of a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> is<P>
a common operation and it is convenient to have a shorthand<P>
for doing it. Further, some implementations may be able to<P>
optimize the presentation of a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> in this mode by<P>
printing it without actually consing the string.<P>
<P>
<B>Current Practice:<P>
</B><P>
Symbolics Genera implements the proposed behavior.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Fairly minor changes to the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> and the printer.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Users who now use the non-portable syntax #S(...) in order<P>
to enter literal pathnames might have to change. [However,<P>
implementations would be free to continue to support this<P>
read syntax for compatibility.]<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
Portability of code and data involving pathnames within a<P>
given file system (or between suitably similar file systems)<P>
would be hampered needlessly.<P>
<P>
<B>Benefits:<P>
</B><P>
The cost of non-adoption would be avoided.<P>
<P>
<B>Aesthetics:<P>
</B><P>
The #P syntax is pretty and hides unimportant details.<P>
<P>
<B>Discussion:<P>
</B><P>
Pitman supports this change.<P>
<P>
-----<P>
Summary of discussion on CL-Cleanup:<P>
<P>
EB noted that Lucid CL implements the proposed behavior and that there<P>
is cost to users who define their own #P read macro. He weakly supports<P>
the proposal but wishes someone had pursued a `generic pathnames' proposal.<P>
<P>
Pierson noted that KCL uses #&quot;...&quot;, but that this collides with proposed<P>
syntax for Dick Waters' pretty printer. He also thinks #P is better<P>
because it is already more widely used for that purpose.<P>
<P>
Masinter noted that Envos Medley prints pathnames with the syntax<P>
#.(<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> &quot;asdf&quot;), which he thinks is not as pretty as #P&quot;asdf&quot;<P>
but currently more portable.<P>
<P>
KMP and JonL raised the issues that #. has the disadvantage that it must<P>
be parsed by the full Lisp engine, while #P can be parsed by something<P>
simpler. Permitting #. leaves a gaping hole for trojan horses, and<P>
also requires the presence of the evaluator in a delivery system.<P>
<P>
MLY, GSB, Peirson, and IIM argued for not using up an extra dispatch<P>
character.<P>
<P>
MLY suggested #S(<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> <A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>namestring</B></A> [optional-host]).<P>
<P>
IIM noted they use #.(<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> <A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>namestring</B></A> host) because different file<P>
systems have different parsing conventions. <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>