medley icon indicating copy to clipboard operation
medley copied to clipboard

Should CL:PATHNAME-DIRECTORY return a list?

Open hjellinek opened this issue 7 months ago • 4 comments

I have a slightly more than vague memory of implementing CL:PATHNAME and its related machinery in the initial Xerox Lisp release that supported Common Lisp. (Koto, was it?)

Specifically, I recall that pathnames represented directory hierarchy as a list.

CLtL2 23.1.3 seems to agree, so I'm reasonably sure I'm remembering things correctly.

I wrote some code that calls IL:DIRECTORY to enumerate the files in a directory, then replaces one of the components of each file's directory hierarchy and... the details don't matter. I created a CL:PATHNAME from each file name and called CL:PATHNAME-DIRECTORY, expecting to receive a list - but I didn't.

Maybe I'm misunderstanding CLtL2? Here's what I saw:

238_ (SETQ PATH (PATHNAME "{DSK}<Users>hjellinek>dir>subdir>foo.bar;7"))
#P"{DSK}<Users>hjellinek>dir>subdir>foo.bar;7"
239_ (SETQ DIR (CL:PATHNAME-DIRECTORY PATH))
<Users>hjellinek>dir>subdir>
240_ (TYPENAME DIR)
DIRECTORY-COMPONENT
241_ (SETQ DIR-PATH (%DIRECTORY-COMPONENT-PATH DIR))
"Users>hjellinek>dir>subdir"
242_ (TYPENAME DIR-PATH)
STRINGP

That is, the directory is an instance of DIRECTORY-COMPONENT, and the PATH field of that object is a string. Nary a list in sight.

The puzzle is: What happened to the code that parsed the directory hierarchy into a list? And is the current implementation compliant with CLtL or CLtL2?

hjellinek avatar May 26 '25 19:05 hjellinek

I can't remember CLtL2, but the ANSI standard is somewhat buggy here: pathname directories can be strings, lists, or some implementation-dependent thing. This issue describes what the list syntax is, but various entries (such as the glossary entry) clearly didn't get updated.

tfeb avatar May 26 '25 22:05 tfeb

I can't remember CLtL2, but the ANSI standard is somewhat buggy here: pathname directories can be strings, lists, or some implementation-dependent thing. This issue describes what the list syntax is, but various entries (such as the glossary entry) clearly didn't get updated.

Thanks, @tfeb. CLtL 2 says (p. 615) "The device, directory, name, and type can be strings" and "The directory can be a list of strings and symbols as described in section 23.1.3." So strings are acceptable, but not what I remember implementing.

So my question boils down to wondering what happened to all that code I wrote to split the directory into a list, as in section 23.1.3. If no Medley veterans can answer (e.g., "Your code was terrible so we replaced it with something simpler"), I'll have to dig in to the archives to try to figure this out.

hjellinek avatar May 26 '25 22:05 hjellinek

there is also https://github.com/masinter/parcftp-cl/blob/main/cl/cleanup/old-mail/pathname-subdirectory-list.mail -- the mail archives of the discussion about the issue.

PATHNAME-SUBDIRECTORY-LIST.mail.txt

There are archives of email for most of the CL issues.

masinter avatar May 27 '25 03:05 masinter

Note that (if I read it correctly) the directory can't be a (non-empty) list of strings in ANSI CL. It needs to be a list whose first element is :absolute or :relative (I forget if there are other options).

The spec entry for pathname-directory inherits text from CLtL2 I think, and is (I think) wrong.

I tested in LW and SBCL and neither accept a list of strings.

tfeb avatar May 27 '25 08:05 tfeb