Subject: Re: (pathname "/tmp/foo/bar/") vs (pathname "/tmp/foo/bar")
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 14 Feb 2004 07:39:02 -0600
Newsgroups: comp.lang.lisp
Message-ID: <6mSdnYSYH5FrubPdXTWc-g@speakeasy.net>
Peter Seibel  <peter@javamonkey.com> 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

and:

    (pathname (namestring yyy)) => yyy

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

    > (namestring (make-pathname :name "bar"))
    "bar"
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo")))
    "/tmp/foo/"
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo")
				 :name "bar"))
    "/tmp/foo/bar"
    > (namestring (make-pathname :directory '(:ABSOLUTE "tmp" "foo" "bar")))
    "/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

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607