logical pathname translations and :device :unspecific

Bug #540263 reported by Nikodemus Siivola
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Confirmed
Low
Unassigned

Bug Description

As per CLHS 19.3.2.1 logical pathnames always have :device :unspecific.

Couple this with how TRANSLATE-PATHNAME works, and it means that physical pathnames translated from logical ones have :device :unspecific on Unix.

Compare this with the same physical pathname parsed from a namestring having :device nil.

CL-USER> (setf (logical-pathname-translations "TEST")
               (list (list "*.TEXT" (make-pathname :device nil
                                                   :directory '(:absolute "tmp")
                                                   :name :wild :type "txt"))))
(("*.TEXT" #P"/tmp/*.txt"))
CL-USER> (translate-logical-pathname "TEST:FOO.TEXT")
#P"/tmp/foo.txt"
CL-USER> (equal * (pathname (namestring *)))
NIL

Damned inconvenient.

Tags: pathnames
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

...and because of the way MERGE-PATHNAMES works physical pathnames parsing with :device :unspecific would be even worse:

;;; Consider Win32.
CL-USER> (pathname-device (merge-pathnames (make-pathname :device :unspecific)
                                           (make-pathname :device "C")))
:UNSPECIFIC

...no, not good.

Revision history for this message
Richard M Kreuter (kreuter) wrote :
Download full text (10.3 KiB)

There are numerous ways to think about addressing this report. For the purpose of this comment, consider two pathnames, p1 and p2, where p1 has :UNSPECIFIC for the device and p2 has NIL, and all other components are EQL respectively.

1. Consideration of EQUAL-ity of p1 and p2.

(a) First, note that this can't happen if p2 is a logical pathname, so the rest of this part of the analysis only applies when p1 and p2 are physical pathnames.

(b) If p1 and p2 are both Unix pathnames, it would be sufficient to define that EQUAL considers :UNSPECIFIC as equivalent to NIL for the device, as two Unix pathnames, p1 and p2, that differ only in that the device of p1 is :UNSPECIFIC and the device of p2 is NIL are ``functionally equivalent'' as objects that might be used to denote filenames.

(One might object that these two pathnames, p1 and p2, are not ``functionally equivalent'' in all possible respects as objects, because, say,

  (when (pathname-device pn)
    (release-the-hounds))

will have different results for p1 and p2. To such an objector it's worth noting that, this program, while conforming, makes no sense: it'd be conforming for an implementation either to canonicalize NIL to :UNSPECIFIC for the device in all Unix pathnames, or conversely to prohibit non-NIL values for the device in all Unix pathnames, etc. IOW: pathnames should not be thought of as bundles of Lisp data, in general, just as objects used as names for things in an exterior world with their own requirements.)

[Aside: I observe that SBCL's EQUAL handles the version component this way, i.e., considers all version component values in Unix pathnames equivalent. So being strict about distinguishing NIL from :UNSPECIFIC for the device on Unix pathnames is odd, to say the least.]

(c) What if p1 and p2 are Windows pathnames?

From a design perspective there's no compelling reason to permit :UNSPECIFIC for the device on Windows, since (IIR/UC) a complete Windows file specification contains for either a drive letter or a UNC path (which I believe SBCL models as :UNC for the device). That is, there is no complete Windows file specification in which the device ``has no meaning'' per 19.2.2.2.3 paragraph 1; and 19.2.2.2.3 paragraph 2 clearly allows the implementation to forbid :UNSPECIFIC for any component.

So the example in comment #1 is arguably a defect in how SBCL implements Windows pathnames, in that SBCL permits an infelicitous result that ANSI does not require.

(d) Sort of an aside, but I'd like to make the explicit observation latent in my points (b) and (c) that Unix pathnames and Windows pathnames don't need to work the same way, and probably shouldn't as far as the device goes: it's equally unnecessary (and sort of silly) that on a Unix host I can make a pathname whose device is :UNC as that on a Windows host it looks like I can make a pathname whose device is :UNSPECIFIC.

2. About TRANSLATE-PATHNAME in general, note that the dictionary entry gives a lot of leeway in the paragraph commencing ``The portion of SOURCE that is copied into the resulting pathname is implementation-defined.'' So it's not required that

  (translate-pathname p1 fp tp)

copy over the :UNSPECIFIC devi...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.