[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I recently found some inconsitency between CLtL2 (Steele) and the
clisp-implementation concerning the `merge-pathnames'-function.

Steele tells in section `23.1.3. Structured Directories':

[... Pathname merging treats a relative directory specially. Let
pathname and defaults be the first two arguments to merge-pathnames.
If (pathname-directory pathname) is a list whose car is :relative, and
(pathname-directory defaults) is a list, then the merged directory is
the value of

(append (pathname-directory defaults)
        (cdr     ;Remove :relative from the front
          (pathname-directory pathname)))

See the following interaction:

(merge-pathnames (make-pathname :directory '(:relative "x"))
                 (make-pathname :directory '(:absolute "y")))
=> #"/y/x/"

(merge-pathnames (make-pathname :directory '(:relative "x"))
                 (make-pathname :directory '(:relative "y")))
=> #"x/"

The first case seems to be ok, but the second one doesn't
behave as expected. In `pathname.d' the code is as follows:

LISPFUN(merge_pathnames,1,2,norest,key,1, (kw(wild)))
# (MERGE-PATHNAMES pathname [defaults [default-version]] [:wild]), CLTL S. 415
# (defun merge-pathnames (pathname &optional (defaults *default-pathname-default
s*) default-version)
#   (setq pathname (pathname pathname))
#   (setq defaults (pathname defaults))


#         :directory
#           (let ((pathname-dir (pathname-directory pathname))
#                 (defaults-dir (pathname-directory defaults)))
#             (if (eq (car pathname-dir) ':RELATIVE)
#               (cond ((null (cdr pathname-dir)) defaults-dir)
#                     ((not (eq (car defaults-dir) ':RELATIVE))
#                      (append defaults-dir (cdr pathname-dir))
#                     )
#                     (t pathname-dir)
#               )
#               pathname-dir
#           ) )

Here, the case that the car of defaults-dir equals :relative, is
an exception to the rule mentioned by Steele. Since the real
implementation seems to work like this Lisp-fragment I'm asking if
there is a reason for this. In `impnotes.txt' there is nothing written
about this case.


Roger Kehr      kehr@iti.informatik.th-darmstadt.de