Re: Pathname vs Make-pathname?
Robert Goldman <rpgoldman@sift.net> writes:
> On 9/10/16 Sep 10 -2:31 PM, Pascal J. Bourguignon wrote:
>>
>> Christopher K Riesbeck <c-riesbeck@northwestern.edu> writes:
>>
>>> I take this to be asking why
>>>
>>> (pathname-name (make-pathname :name "”))
>>>
>>> returns NIL. This happens in Lispworks on both MacOS and Windows, but
>>> not in Allegro or SBCL.
>>
>> Cf. 19.2.2.5:
>>
>> * The host, device, directory, name, and type can be strings. There
>> are implementation-dependent limits on the number and type of
>> characters in these strings.
>>
>> Therefore you should be very conservative on the length of the strings
>> you pass to make-pathname. An empty string is probably not a valid
>> pathname component on at least some implementations. A string longuer
>> than 5 or 7 for the name component is probably out of bounds on some
>> implementations too.
>>
>> For the type you will have even stronger limitations.
>>
>>
>> Furthermore:
>>
>> 19.3.2.2 Null Strings as Components of a Logical Pathname
>>
>> The null string, "", is not a valid value for any component of a
>> logical pathname.
>>
>>
>>
>> So since I would advice to always use logical pathnames, an empty string
>> is definitely something you should not use.
>>
>>
>
> I'm surprised to hear this advice. Our experience in ASDF has been
> precisely the opposite: because of their limitations, we *avoid* logical
> pathnames (although ASDF does support them). Their behavior with
> commonly used pathname constituents (mixed-case, underscores) is either
> failure, or inconsistent behavior across implementations.
Logical pathname components cannot have mixed-case or underscores, etc.
The only valid (conforming) characters in logical pathname components
are A-Z 0-9, #\. and #\-.
cf. 19.3.1: word---one or more uppercase letters, digits, and hyphens.
And indeed, since physical pathnames are purely implementation
dependant, the "automatic" mapping between logical pathnames and
physical pathnames is purely implementation dependent.
The only conforming thing you can do here, is starting from a list of
physical pathnames, to build logical pathnames, establishing an explicit
mapping thru logical pathname translations (therefore with absolutely no
wild card).
When you do that, everything is bliss! :-)
> E.g., if you
> provide a system that will load files relative to a logical pathname in
> your configuration, and a user enters a pathname containing an
> underscore.... bad things will happen.
Of course. Why would you accept an underscore? Only uppercase letters,
digits, dot and dash.
> Logical pathnames were a reasonable approach for a time when filesystems
> (and operating systems) were much more diverse than they are today.
> Today they are simply too constraining.
While logical pathnames might be overkill to deal with POSIX paths,
neither physical pathnames nor CL STRING are adapted to them. The
semantics of POSIX paths, and file system mounting is such that the only
safe way to deal with POSIX paths, is to deal with them as what they
are: vectors of octets (excluding 0, 47 being the component separator).
> One of the challenges Faré addressed in UIOP was to make file system
> interaction as consistent as possible across platforms (and even so,
> results are still inconsistent).
And then, MS-Windows and MS-DOS paths are not POSIX paths since instead
of using 47, they use 92, and there's this device prefix (that while it
could be mapped to CL pathname-device, is often not, in anycase it's
implementation dependent).
Notice also that MacOSX also deals with MacOS paths (components
separated with ":", but I'm not sure if the unix layer does, or if it's
only in the Cocoa layer and the user interface).
In any case, there's still space for logical pathnames in the
contemporaneous environment.
(For example, iolib/syscall which should know better, converts vectors
of octets into lisp strings using a utf-8 encoding (escaping with a
#\Nul the octets that are not valid utf-8 sequences). What about file
systems using iso-8859-1, windows-1250, or cp830?
You may get botched components. )
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html