Subject: Re: (pathname "/tmp/foo/bar/") vs (pathname "/tmp/foo/bar")
From: (Rob Warnock)
Date: Sat, 14 Feb 2004 07:39:02 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Peter Seibel  <> wrote:
| Among all the various wrinkles in interpretation and implementation
| choices around pathnames, all the Unix-based Common Lisp's I've tested
| seem to agree that:
|   (pathname-directory "/tmp/foo/bar") ==> (:ABSOLUTE "tmp" "foo")
| while:
|   (pathname-directory "/tmp/foo/bar/") ==> (:ABSOLUTE "tmp" "foo" "bar")
| I.e. the trailing '/' on the namestring controls whether the last
| element goes into the directory component of the pathname.

It would seem logical that this is pretty much required if one wants
pathname/namestring invariance, that is, if we want:

    (namestring (pathname xxx)) => xxx


    (pathname (namestring yyy)) => yyy

Perhaps some NAMESTRING examples may be helpful (albeit non-normative):

    > (namestring (make-pathname :name "bar"))
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo")))
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo")
				 :name "bar"))
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo" "bar")))

So namestrings need *some* convention to distinguish the 3rd & 4th cases,
otherwise you couldn't get the same pathname back [second invariant above].


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607