214 lines
14 KiB
HTML
214 lines
14 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 LOAD-TRUENAME 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/iss216_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss218.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss219_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/iss216_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss218.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss219_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue LOAD-TRUENAME Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Passed, Jun 89 X3J13<P>
|
|
<P>
|
|
<B>Issue:</B> <A HREF="iss218.htm">LOAD-TRUENAME</A><P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> (p426), <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>PROVIDE</B></A> (p188), <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>REQUIRE</B></A> (p188),<P>
|
|
Issue <A HREF="iss296.htm">REQUIRE-PATHNAME-DEFAULTS</A><P>
|
|
<B>Category:</B> ADDITION<P>
|
|
<B>Edit history:</B> 13-Mar-89, Version 1 by Pitman<P>
|
|
29-Mar-89, Version 2 by Moon (add -PATHNAME vars)<P>
|
|
10-Apr-89, Version 3 by Pitman (clarify v2)<P>
|
|
11-Apr-89, Version 4 by Pitman (merge Moon's v3 comments)<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
It is difficult to construct sets of software modules which work<P>
|
|
together as a unit and which port between different implementations.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>REQUIRE</B></A> and <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>PROVIDE</B></A> were intended to <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> this level of support<P>
|
|
but have `failed' to be portable in practice.<P>
|
|
<P>
|
|
Typical user configurations involve a `system definition' file which<P>
|
|
loads the modules of a `system' (collection of software modules).<P>
|
|
<P>
|
|
Among the specific problems which arise are:<P>
|
|
<P>
|
|
- File system types may vary. Different file syntax must be used for<P>
|
|
each site.<P>
|
|
<P>
|
|
- Even with the same Lisp implementation and host file system type,<P>
|
|
the directory in which a software system resides may differ from<P>
|
|
delivery site to delivery site.<P>
|
|
<P>
|
|
- Multiple `copies' of the same system may reside in different<P>
|
|
directories on the same machine.<P>
|
|
<P>
|
|
<B>Proposal (LOAD-TRUENAME:NEW-PATHNAME-VARIABLES):<P>
|
|
</B><P>
|
|
Introduce new variables:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_ld_pns.htm#STload-truenameST"><B>*LOAD-TRUENAME*</B></A> [Variable]<P>
|
|
<P>
|
|
This special variable is initially <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, but is bound by <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> to<P>
|
|
hold the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A> of the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> of the file being loaded.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_cmp_fi.htm#STcompile-file-truenameST"><B>*COMPILE-FILE-TRUENAME*</B></A> [Variable]<P>
|
|
<P>
|
|
This special variable is initially <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, but is bound by <P>
|
|
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> to hold the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A> of the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> of the file<P>
|
|
being compiled.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_ld_pns.htm#STload-pathnameST"><B>*LOAD-PATHNAME*</B></A> [Variable]<P>
|
|
<P>
|
|
This special variable is initially <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> but is bound by <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A><P>
|
|
to hold a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> which represents the filename given as the<P>
|
|
first argument to <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> merged against the defaults.<P>
|
|
That is, (<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> (<A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A> arg1)).<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/v_cmp_fi.htm#STcompile-file-pathnameST"><B>*COMPILE-FILE-PATHNAME*</B></A> [Variable]<P>
|
|
<P>
|
|
This special variable is initially <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> but is bound by <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A><P>
|
|
to hold a <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> which represents the filename given as the<P>
|
|
first argument to <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> merged against the defaults.<P>
|
|
That is, (<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> (<A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A> arg1)).<P>
|
|
<P>
|
|
<B>Example:<P>
|
|
</B><P>
|
|
------ File SETUP ------<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_in_pkg.htm#in-package"><B>IN-PACKAGE</B></A> "MY-STUFF")<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> COMPILE-TRUENAME () `',<A REL=DEFINITION HREF="../Body/v_cmp_fi.htm#STcompile-file-truenameST"><B>*COMPILE-FILE-TRUENAME*</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> *MY-COMPILE-TRUENAME* (COMPILE-TRUENAME) "Just for debugging.")<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> *MY-LOAD-PATHNAME* <A REL=DEFINITION HREF="../Body/v_ld_pns.htm#STload-pathnameST"><B>*LOAD-PATHNAME*</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> LOAD-MY-SYSTEM ()<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>DOLIST</B></A> (MODULE-NAME '("FOO" "BAR" "BAZ"))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> (<A REL=DEFINITION HREF="../Body/f_merge_.htm#merge-pathnames"><B>MERGE-PATHNAMES</B></A> MODULE-NAME *MY-LOAD-PATHNAME*))))<P>
|
|
------------------------<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> "SETUP")<P>
|
|
(LOAD-MY-SYSTEM)<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This satisfies the most common instances of the frequently reported<P>
|
|
problem in the Problem Description.<P>
|
|
<P>
|
|
The ...-TRUENAME* variables are useful to tell the real file being<P>
|
|
loaded.<P>
|
|
<P>
|
|
The ...-PATHNAME* variables are useful to find information about<P>
|
|
the original link names or logical device names mentioned in the<P>
|
|
<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> to be opened but no longer reflected in the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A>.<P>
|
|
<P>
|
|
Note that it is not adequate to just have the -PATHNAME* variables<P>
|
|
since <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>TRUENAME</B></A> on these pathnames might not yield the value of the<P>
|
|
-TRUENAME* variables if the file has been deleted or protected<P>
|
|
since the open occurred (in some implementations).<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Wide variation.<P>
|
|
<P>
|
|
In some implementations, calling <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> binds or sets <P>
|
|
<A REL=DEFINITION HREF="../Body/v_defaul.htm#STdefault-pathname-defaultsST"><B>*DEFAULT-PATHNAME-DEFAULTS*</B></A> so that pathnames named in a file being<P>
|
|
LOADed will default to being `nearby.'<P>
|
|
<P>
|
|
Some implementations <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> special variables that are similar or<P>
|
|
identical to one or both of those proposed.<P>
|
|
<P>
|
|
Some implementations have a way to represent the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> for the<P>
|
|
current working directory, and make the default <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> default<P>
|
|
to that, so that loading without specifying a default again tends to<P>
|
|
get `nearby' files.<P>
|
|
<P>
|
|
None of these techniques is portable, unfortunately, because there<P>
|
|
is no agreement.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Very small.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
None. This change is upward compatible.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Continued difficulty for anyone trying to put a system of modules<P>
|
|
in a form where they can be conveniently delivered using portable code.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
The cost of non-adoption is avoided.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
Negligible.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Touretzky raised the issue most recently on Common-Lisp. A number<P>
|
|
of people immediately jumped on the bandwagon, indicating it was<P>
|
|
important to them, too.<P>
|
|
<P>
|
|
Pitman made three suggestions in response, of which the above is<P>
|
|
the first. The others included:<P>
|
|
2. Variables *LOAD-TRUENAMES* and *COMPILE-FILE-TRUENAMES* which hold<P>
|
|
lists of the truenames of all files being loaded or compiled,<P>
|
|
respectively, during the dynamic invocation of <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> and <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>.<P>
|
|
<P>
|
|
3. Variable *LOAD-OR-COMPILE-FILE-TRUENAMES* which holds a list like<P>
|
|
((<A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A>) (<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A>) ...)<P>
|
|
during the dynamic invocation of <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> and <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>.<P>
|
|
<P>
|
|
Touretzky responded:<P>
|
|
``I like KMP's proposals. I like the second one best: have separate<P>
|
|
variables for files being loaded and files being compiled, and use<P>
|
|
them to maintain a stack so we can see the nesting of loads within<P>
|
|
files.''<P>
|
|
<P>
|
|
Pitman ultimately chose to present the first rather than the second<P>
|
|
because it seemed simpler, easier to explain, and more likely to<P>
|
|
pass at this late date.<P>
|
|
<P>
|
|
Other suggestions which were considered discarded were:<P>
|
|
a. Provide just variables *LOAD-STREAM* and *COMPILE-FILE-STREAM*.<P>
|
|
Then <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> and <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>TRUENAME</B></A> could be used to yield the <P>
|
|
information contained in the -PATHNAME* and -TRUENAME* variables<P>
|
|
of the proposal above.<P>
|
|
b. Like (a), but call both variables <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A>. That is,<P>
|
|
say that <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> and <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> bind <A REL=DEFINITION HREF="../Body/v_debug_.htm#STstandard-inputST"><B>*STANDARD-INPUT*</B></A> to the<P>
|
|
stream being loaded.<P>
|
|
There were a number of pitfalls with this approach which all center<P>
|
|
around the way it invites the user to do other operations besides<P>
|
|
<A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>PATHNAME</B></A> and <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>TRUENAME</B></A>. Not only would some people be confused by<P>
|
|
the difference between the characteristics of *LOAD-STREAM* for<P>
|
|
compiled and interpreted files, but also even with interpreted <P>
|
|
streams, the actual position of the stream pointer at the time of<P>
|
|
execution of the forms contained in the file could vary between<P>
|
|
implementations in a way that became a lurking portability barrier.<P>
|
|
Since the observed user need which spawned this discussion was for<P>
|
|
a way to tell what file was being loaded and not for a way to <P>
|
|
manipulate the stream, it seemed best to just go with the variables<P>
|
|
that addressed that specific need--fewer pitfalls and more perspicuous<P>
|
|
code are likely to result.<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>
|