>>>>> "Sam" == Sam Steingold <sds@...> writes:
Sam> Raymond Toy wrote:
>>>>>>> "Sam" == Sam Steingold <sds@...> writes:
Sam> http://clisp.cons.org/impnotes/filename-misc.html#parsename
>> Is it really confusing about parsing "c:/autoexec.bat",
>> "home:.clisprc", and "prep:/pub/gnu" according to ANSI rules?
Sam> what is "c:autoexec.bat"?
Sam> is it a physical pathname or a logical one?
As I said, you'd have to see if logical hosts were defined or not.
Or you could just (translate-logical-pathname "c:autoexec.bat") and
see what comes out.
Or use (typep (pathname "c:autoexec.bat") 'logical-pathname), but
Clisp's PATHNAME isn't ANSI by default, so that's not very useful.
Naemstrings don't live in a vacuum, so you need context (an OS) in
this case to figure out what it means anyway.
>> Well, I guess you'd need to look to see if you have logical hosts
>> names "c", "home" or "prep". And I guess the parsing would change if
>> you suddenly defined logical hosts. But people don't really do that
>> except to play games and screw things up intentionally. :-)
>> But "prep:/pub/gnu" clearly can't be a logical pathname because it
>> has
>> illegal characters.
Sam> when you type explicit pathnames at the command line by hand, the
Sam> confusion is minimal - you know what you mean.
Sam> when the pathname comes from munching a few user variables, reading
Sam> files and environment &c, the confusion can be huge.
I guess. I don't do that kind of stuff so I wouldn't know. And I
don't run Lisp on windows, so "c:autoexec.bat" is a phyiscal pathname
unless I defined the logical host "C".
Ray

Raymond Toy wrote:
>>>>>> "Sam" == Sam Steingold <sds@...> writes:
> Sam> http://clisp.cons.org/impnotes/filename-misc.html#parsename
>
> Is it really confusing about parsing "c:/autoexec.bat",
> "home:.clisprc", and "prep:/pub/gnu" according to ANSI rules?
what is "c:autoexec.bat"?
is it a physical pathname or a logical one?
> Well, I guess you'd need to look to see if you have logical hosts
> names "c", "home" or "prep". And I guess the parsing would change if
> you suddenly defined logical hosts. But people don't really do that
> except to play games and screw things up intentionally. :-)
>
> But "prep:/pub/gnu" clearly can't be a logical pathname because it has
> illegal characters.
when you type explicit pathnames at the command line by hand, the confusion is
minimal - you know what you mean.
when the pathname comes from munching a few user variables, reading files and
environment &c, the confusion can be huge.

>>>>> "Sam" == Sam Steingold <sds@...> writes:
Sam> Raymond Toy wrote:
>> Is there any way to make (typep <something> 'logical-pathname) be T?
Sam> (logical-pathname "foo:bar;baz.zot")
How silly of me! I didn't see that.
>> I'm not exactly sure how translate-logical-pathname can work according
>> to the spec:
>> Pathname is first coerced to a pathname. If the coerced pathname
>> is a physical pathname, it is returned. If the coerced pathname is
>> a logical pathname, the first matching translation (according to
>> pathname-match-p) of the logical pathname host is applied, as if
>> by calling translate-pathname. If the result is a logical
>> pathname, this process is repeated. When the result is finally a
>> physical pathname, it is returned. If no translation matches, an
>> error is signaled.
>> (pathname "foo:abc.lisp") returns a physical pathname and hence
>> translate-logical-pathname should return #p"foo:abc.lisp". Instead
>> (translate-logical-pathname "foo:abc.lisp") returns #P"/tmp/abc.lisp",
>> which seems not right, but, of course, the useful answer.
Sam> translate-logical-pathname always returns a physical pathname - that's
Sam> its raison d'etre.
Yes, but the spec says it's coerced to a pathname first, so
"foo:abc.lisp" is converted to the phyiscal pathname, which is what
translate-logical-pathname should return.
But I now understand why clisp doesn't return #p"foo:abc.lisp". If it
did, translate-logical-pathname would be useless on clisp if it did
convert to a pathname first.
Sam> whether (pathname "foo:abc.lisp") returns a logical or a physical
Sam> pathname depends on CUSTOM:*PARSE-NAMESTRING-ANSI*, see
Sam> http://clisp.cons.org/impnotes/filename-misc.html#parsename
I did look through the impnotes before sending this. I just missed
the stuff about parse-namestring and such.
Is it really confusing about parsing "c:/autoexec.bat",
"home:.clisprc", and "prep:/pub/gnu" according to ANSI rules?
Well, I guess you'd need to look to see if you have logical hosts
names "c", "home" or "prep". And I guess the parsing would change if
you suddenly defined logical hosts. But people don't really do that
except to play games and screw things up intentionally. :-)
But "prep:/pub/gnu" clearly can't be a logical pathname because it has
illegal characters.
Ray

Raymond Toy wrote:
>
> Is there any way to make (typep <something> 'logical-pathname) be T?
(logical-pathname "foo:bar;baz.zot")
> I'm not exactly sure how translate-logical-pathname can work according
> to the spec:
>
> Pathname is first coerced to a pathname. If the coerced pathname
> is a physical pathname, it is returned. If the coerced pathname is
> a logical pathname, the first matching translation (according to
> pathname-match-p) of the logical pathname host is applied, as if
> by calling translate-pathname. If the result is a logical
> pathname, this process is repeated. When the result is finally a
> physical pathname, it is returned. If no translation matches, an
> error is signaled.
>
> (pathname "foo:abc.lisp") returns a physical pathname and hence
> translate-logical-pathname should return #p"foo:abc.lisp". Instead
> (translate-logical-pathname "foo:abc.lisp") returns #P"/tmp/abc.lisp",
> which seems not right, but, of course, the useful answer.
translate-logical-pathname always returns a physical pathname - that's its
raison d'etre.
whether (pathname "foo:abc.lisp") returns a logical or a physical pathname
depends on CUSTOM:*PARSE-NAMESTRING-ANSI*, see
http://clisp.cons.org/impnotes/filename-misc.html#parsename

Let's say we have:
(setf (logical-pathname-translations "foo")
'(("**;*.*.*" #p"/tmp/**/*.*")))
Is there any way to make (typep <something> 'logical-pathname) be T?
(Well, short of using #S(logical-pathname ...).)
I'm not exactly sure how translate-logical-pathname can work according
to the spec:
Pathname is first coerced to a pathname. If the coerced pathname
is a physical pathname, it is returned. If the coerced pathname is
a logical pathname, the first matching translation (according to
pathname-match-p) of the logical pathname host is applied, as if
by calling translate-pathname. If the result is a logical
pathname, this process is repeated. When the result is finally a
physical pathname, it is returned. If no translation matches, an
error is signaled.
(pathname "foo:abc.lisp") returns a physical pathname and hence
translate-logical-pathname should return #p"foo:abc.lisp". Instead
(translate-logical-pathname "foo:abc.lisp") returns #P"/tmp/abc.lisp",
which seems not right, but, of course, the useful answer.
BTW, this is clisp 2.47, on Solaris.
Ray