Subject: make-pathname and :defaults
From: Erik Naggum <clerik@naggum.no>
Date: 1997/12/28
Newsgroups: comp.lang.lisp
Message-ID: <3092329672760284@naggum.no>


I'm a little confused about the `defaults' arguments to `make-pathname'.
naïvely, I had imagined that the following two forms would yield the same
value:

    (make-pathname :directory '(:relative "foo")
		   :name "bar"
		   :defaults (user-homedir-pathname))
    => #p"foo/bar"

    (merge-pathnames (make-pathname :directory '(:relative "foo")
				    :name "bar")
		     (user-homedir-pathname))
    => #p"/home/erik/foo/bar"

but this is not so in Allegro 4.3.1 for Unix or in CMUCL 17f, which agree
on the values.

the specification for `make-pathname' reads (quoted from the HyperSpec):

    After the components supplied explicitly by HOST, DEVICE, DIRECTORY,
    NAME, TYPE, and VERSION are filled in, the merging rules used by
    `merge-pathnames' are used to fill in any _unsupplied_ components from
    the defaults supplied by DEFAULTS.  [my emphasis]

standing by itself, this could be taken to support the implementation in
ACL 4.3.1 and CMUCL 17f, but the specification for `merge-pathnames' reads:

    Constructs a pathname from PATHNAME by filling in any _unsupplied_
    components with the corresponding values from DEFAULT-PATHNAME and
    DEFAULT-VERSION.  [my emphasis]

which might be interpreted to mean that "unsupplied" in `make-pathname' and
`merge-pathnames' are the same, and then defined only in `merge-pathnames',
whose specification goes on to say:

    Pathname merging treats a relative directory specially.  If
    (pathname-directory pathname) is a list whose car is :relative, and
    (pathname-directory default-pathname) is a list, then the merged
    directory is the value of

	(append (pathname-directory default-pathname)
		(cdr  ;remove :relative from the front
		  (pathname-directory pathname)))

    except [specification of :back processing].

which is clearly intended to _override_ the meaning of "unsupplied" in
entirely intuitive ways.

my question is whether the special treatment of relative directories also
overrides the "unsupplied" in `make-pathname' since it defers the handling
of "unsupplied" arguments to `merge-pathnames'.  I would tend to think it
should.  comments?  (Kent?)

#\Erik
-- 
The year "98" was new 1900 years ago.  |  Help fight MULE in GNU Emacs 20!
Be year 2000 compliant, write "1998"!  |  http://sourcery.naggum.no/emacs/