Re: pathname-directory, Hyperspec violation

JP Massar <[email protected]>
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
At 08:57 AM 2/25/03 +0000, SmallHairyTroll <[email protected]> wrote:
>I am trying to pass a filename and directoryname string to the
>function (make-pathname) like so...
>
>(setf path (make-pathname
>         :device "C"
>         :directory '("\\test_directory")
>         :name "test_file.txt"))
>
>... ccl returns ...
>
>#P"C:test_file.txt"
>
>... what happened to the directoryname ? I'm doing something wrong
>but what?

If you look at the components of the structure returned, you will see
that the "\\test_directory" string is part of the :directory slot.

But it doesn't get printed out.  I think that's because the printer assumes
the first element of the :directory slot should be :absolute or :relative,
which is a reasonable assumption.

I would venture that there are a fair number of problems with pathnames,
e.g., this is a violation of the Hyperspec, related to the above:

(setf path (make-pathname
         :device "C"
         :directory '(:absolute "test_directory")
         :name "test_file.txt"))
#P"C:\test_directory\test_file.txt"
(setf path (make-pathname
         :device "C"
         :directory "test_directory"
         :name "test_file.txt"))
;;; An error occurred in function CONVERT-PATHNAME-TO-NAMESTRING:
;;; Error: Not a list: test_directory
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1   Abort to top level.

because the MAKE-PATHNAME entry in the Hyperspec says that

"If the directory is a string, it should be the name of a
top level directory, and should not contain any punctuation
characters; that is, specifying a string, str, is equivalent
to specifying the list (:absolute str)."

Also, it says that the directory component is

'a valid pathname directory'

and the entry for 'valid pathname directory' says that it is

"string, a list of strings, nil, :wild, :unspecific, or some
other object defined by the implementation to be a
valid directory component."

So MAKE-PATHNAME must clearly accept a string as the argument
for the :DIRECTORY keyword, but it is not.  And it also certainly
should accept a list of one string and treat it as a string.
OTOH, your example has 'punctuation' in it so it could be
considered erroneous, and all bets are off at that point.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.