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

241 lines
16 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-COMPONENT-CASE 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/iss255_w.htm">
<LINK REL=UP HREF="../Issues/iss256.htm">
<LINK REL=NEXT HREF="../Issues/iss257_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/iss255_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss256.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss257_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue PATHNAME-COMPONENT-CASE Writeup</H2>
<PRE><B>Status:</B> passed, as amended here, Jun 89 X3J13<P>
<B>Issue:</B> <A HREF="iss256.htm">PATHNAME-COMPONENT-CASE</A><P>
<B>References:</B> Pathnames (pp410-413),<P>
<A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> (p416),<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-host"><B>PATHNAME-HOST</B></A> (p417),<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-device"><B>PATHNAME-DEVICE</B></A> (p417),<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-directory"><B>PATHNAME-DIRECTORY</B></A> (p417),<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (p417),<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-type"><B>PATHNAME-TYPE</B></A> (p417)<P>
Related-issues: <A HREF="iss267.htm">PATHNAME-WILD</A><P>
<B>Category:</B> CHANGE<P>
<B>Edit history:</B> 1-Jul-88, Version 1 by Pitman<P>
22-Mar-89, Version 2 by Moon, update and rewrite<P>
9-May-89, Version 3 by Moon, remove alternate proposals<P>
9-May-89, Version 4 by Moon, respond to discussion with KMP<P>
17-Jun-89, Version 5 by Moon, fix typo, make minor improvements<P>
to the presentation.<P>
1-Jul-89, Version 6 by Masinter, as per Jun89X3J13 amendments<P>
<P>
<B>Problem Description:<P>
</B><P>
Issues of alphabetic case in pathnames are a major source of problems.<P>
In some file systems, the customary case is lowercase, in some uppercase,<P>
in some mixed. In some file systems, case matters, in others it does<P>
not.<P>
<P>
There are two kinds of <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> case portability problems: moving<P>
programs from one Common Lisp to another, and moving <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> component<P>
values from one file system to another. To solve the first problem, all<P>
Common Lisp implementations that support a particular file system must<P>
use compatible representations for <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> component values. To solve<P>
the second problem, there must be a common representation for the least<P>
common denominator <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> component values that exist on all<P>
interesting file systems.<P>
<P>
This desire for a common representation directly conflicts with the<P>
desire among programmers who only use one file system to work with the<P>
local conventions and not think about issues of porting to other file<P>
systems. The common representation cannot be the same as every local<P>
convention, since they vary.<P>
<P>
In the current anarchy of <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> component case conventions:<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A> (<A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> :NAME &quot;FOO&quot; :TYPE &quot;LISP&quot;))<P>
will produce foo.lisp in some Unix Common Lisp implementations<P>
and will produce FOO.LISP in other Unix Common Lisp implementations.<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A> (<A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> :NAME &quot;foo&quot; :TYPE &quot;lisp&quot;))<P>
will produce FOO.LISP in some Tops-20 Common Lisp implementations<P>
and will produce &quot;^Vf^Vo^Vo.^Vl^Vi^Vs^Vp&quot;in other Tops-20 Common<P>
Lisp implementations.<P>
<P>
Problems like this make it difficult to use <A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> for much of<P>
anything without corrective (non-portable) code.<P>
<P>
Other problems occur in merging because doing<P>
(<A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A> (<A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A> (<A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> :HOST &quot;MY-TOPS-20&quot; :NAME &quot;FOO&quot;)<P>
(<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-UNIX:x.lisp&quot;)))<P>
should probably return &quot;MY-TOPS-20:FOO.LISP&quot; but in fact might return<P>
&quot;MY-TOPS-20:FOO.^Vl^Vi^Vs^Vp&quot; in some implementations.<P>
<P>
Problems like this make it difficult to use any merging primitives for<P>
much of anything without corrective (non-portable) code.<P>
<P>
<B>Proposal (PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT):<P>
</B><P>
Add a keyword argument :CASE to <A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-host"><B>PATHNAME-HOST</B></A>,<P>
<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-device"><B>PATHNAME-DEVICE</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-directory"><B>PATHNAME-DIRECTORY</B></A>, <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A>, and <A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-type"><B>PATHNAME-TYPE</B></A>.<P>
The possible values for the argument are :COMMON and :LOCAL.<P>
<P>
:LOCAL means strings input to <A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> or output by PATHNAME-xxx<P>
follow the local file system's conventions for alphabetic case.<P>
Strings given to <A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> will be used exactly as written if<P>
the file system supports both cases. If the file system only<P>
supports one case, the strings will be translated to that case.<P>
<P>
:COMMON means strings input to <A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> or output by PATHNAME-xxx<P>
follow this common convention:<P>
- all uppercase means to use a file system's customary case.<P>
- all lowercase means to use the opposite of the customary case.<P>
- mixed case represents itself.<P>
The second and third bullets exist so that translation from local to<P>
common and back to local is information-preserving.<P>
<P>
The default is :LOCAL.<P>
<P>
Namestrings always use local file system case conventions.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A> and TRANSLATE-WILD-PATHNAME map customary case in the<P>
input pathnames into customary case in the output <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A>.<P>
<P>
<B>Implications of the proposal:<P>
</B><P>
Unix is case-sensitive and prefers lowercase, so it translates between<P>
common and local by inverting the case of non-mixed-case strings.<P>
<P>
Tops-20 is case-sensitive and prefers uppercase, so it uses identical<P>
representations for common and local.<P>
<P>
VAX/VMS is upper-case-only (that is, the file system translates all file<P>
name arguments to upper case), so it translates common to local by<P>
upcasing, and translates local to common with no change.<P>
<P>
Macintosh is case-insensitive and prefers lowercase, so it translates<P>
between common and local by inverting the case of non-mixed-case strings,<P>
and ignores case in <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> of two pathnames.<P>
<P>
<B>Test Case/Examples:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-UNIX:/me/foo.lisp&quot;)<P>
:CASE :COMMON) =&gt; &quot;FOO&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-TOPS-20:&lt;ME&gt;FOO.LISP&quot;)<P>
:CASE :COMMON) =&gt; &quot;FOO&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-UNIX:/me/foo.lisp&quot;)<P>
:CASE :LOCAL) =&gt; &quot;foo&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-TOPS-20:&lt;ME&gt;FOO.LISP&quot;)<P>
:CASE :LOCAL) =&gt; &quot;FOO&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-UNIX:/me/TeX.lisp&quot;)<P>
:CASE :COMMON) =&gt; &quot;TeX&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-name"><B>PATHNAME-NAME</B></A> (<A REL=DEFINITION HREF="../Body/f_pars_1.htm#parse-namestring"><B>PARSE-NAMESTRING</B></A> &quot;MY-UNIX:/me/TeX.lisp&quot;)<P>
:CASE :LOCAL) =&gt; &quot;TeX&quot;<P>
(<A REL=DEFINITION HREF="../Body/f_namest.htm#namestring"><B>NAMESTRING</B></A> (<A REL=DEFINITION HREF="../Body/f_mk_pn.htm#make-pathname"><B>MAKE-PATHNAME</B></A> :HOST &quot;MY-UNIX&quot; :NAME &quot;FOO&quot;<P>
:CASE :COMMON) =&gt; &quot;MY-UNIX:foo&quot;<P>
<P>
<B>Rationale:<P>
</B><P>
This does not solve the whole <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> problem, but it does improve<P>
the situation for a clearly defined set of very common problems.<P>
Together with the other <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> proposals, the behavior of pathnames<P>
should be sufficiently consistent across Common Lisp implementations<P>
and across file systems to allow portability of pathname-manipulating<P>
programs.<P>
<P>
The current situation where different implementations talk about<P>
the *same* file system in different ways will be corrected by this<P>
and some of the other <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> proposals.<P>
<P>
Upper case is chosen as the common case for no better reason than<P>
consistency with Lisp symbols.<P>
<P>
The :CASE keyword argument provides access to both common and local<P>
conventions without introducing any new functions. The default<P>
convention is the common one, assuming that most programs are fully<P>
portable and therefore :COMMON will be more frequently used.<P>
<P>
<B>Current Practice:<P>
</B><P>
There are no known implementations of exactly what is proposed.<P>
Symbolics Genera uses common case normally, and provides a way to<P>
access the local case (called &quot;raw&quot;) that in practice is rarely used.<P>
Symbolics Genera's own file system is case-insensitive and uses lower<P>
case as the customary case, but transparent network access is available<P>
to file systems using all known case conventions.<P>
<P>
Several Common Lisp implementations behave as if :CASE :LOCAL was<P>
specified (but accept no :CASE argument).<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
The :CASE feature is easily added, but some implementations may have<P>
to change the default behavior when :CASE is not specified. No<P>
implementation need change its internal representation, nor the way<P>
pathnames print, just the interface functions listed above.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Technically, this change is upward compatible.<P>
<P>
In fact, since the existing CLtL spec is so poor, nearly everyone relies<P>
heavily on implementation-specific behavior since there is little other<P>
choice. As such, any change is almost certain to break lots of programs,<P>
in usually superficial but nevertheless important ways. However, if we<P>
really make the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> facility more portable, the user community may<P>
be willing to bear the consequences of these changes.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
We would be contributing to the perpetuation of the existing fiasco of a<P>
<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> system.<P>
<P>
<B>Performance Impact:<P>
</B><P>
None.<P>
<P>
<B>Benefits:<P>
</B><P>
One step closer to a usable <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> system.<P>
<P>
<B>Aesthetics:<P>
</B><P>
Anything that simplifies the user model of pathnames is an improvement.<P>
<P>
<B>Discussion:<P>
</B><P>
Some people would rather use lowercase as the common case. The<P>
decision is essentially arbitrary. Everywhere else in Common Lisp<P>
where case matters, uppercase was chosen.<P>
<P>
It has been proposed that the Common Lisp specification should include<P>
specifications of the exact behavior of pathnames for several popular<P>
operating systems, so that multiple implementations for those<P>
operating systems would be compatible with each other. This proposal<P>
does that for alphabetic case.<P>
<P>
Some people want the default for :CASE to be :LOCAL instead of :COMMON.<P>
See Rationale.<P>
<P>
There should probably be a remark somewhere that says that portable<P>
programs shouldn't expect to be able to create and/or access distinct<P>
files whose <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> components differ only in case.<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>