In LispWorks:
(make-pathname :name "root") ; --> #p"root"
(make-pathname :name "/root") ; --> #p"/root"
In CLISP (windows):
(make-pathname :name "root") ; --> #p"root"
(make-pathname :name "/root") ; --> error
The error is:
*** - MAKE-PATHNAME: illegal :NAME argument "/root"
If it makes a difference i don't have a directory called /root.
Which is the correct behaviour?
Geoffrey King wrote:
> In LispWorks:
> (make-pathname :name "root") ; --> #p"root"
> (make-pathname :name "/root") ; --> #p"/root"
>
> In CLISP (windows):
> (make-pathname :name "root") ; --> #p"root"
> (make-pathname :name "/root") ; --> error
>
> The error is:
> *** - MAKE-PATHNAME: illegal :NAME argument "/root"
>
> If it makes a difference i don't have a directory called /root.
>
> Which is the correct behaviour?
I think CLISP is closer to correct, at least on Unix: the name
component of a pathname is generally interpreted as the name part of a
file, as distinct from any directory part and on Unix file names in
this sense can't contain slashes. But they can on other systems, so it
depends on a lot of factors. If you want to convert a namestring into
a pathname object it's generally better to use PARSE-NAMESTRING or the
PATHNAME function, and let the system decide what parts are what.
(a clearer example of why what you're trying to do is going to lead to
bad things is something like:
(make-pathname :directory (:absolute "usr" "local") :name "/foo")
)
--tim
Geoffrey King <··············@optushome.com.au> writes:
> Which is the correct behaviour?
Maybe you want:
(make-pathname :directory '(:absolute) :name "root") --> #p"/root"
Petter
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
+ Geoffrey King <··············@optushome.com.au>:
| In CLISP (windows):
| (make-pathname :name "root") ; --> #p"root"
| (make-pathname :name "/root") ; --> error
|
| The error is:
| *** - MAKE-PATHNAME: illegal :NAME argument "/root"
|
| If it makes a difference i don't have a directory called /root.
In addition to the other responses, I may add that, if you really want
this pathname to point to a directory called root as opposed to an
ordinary file of that name, you probably want this:
(make-pathname :directory (list :absolute "root")) ; => #P"/root/"
That said, you may also wish to look at Peter Seibel's portable
pathname library:
http://gigamonkeys.com/book/practical-a-portable-pathname-library.html
That is, if you're trying to solve a real-world problem rather than
just asking academic questions about standards conformance. 8-)
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell