[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: merge-pathnames
Roger Kehr <kehr@iti.informatik.th-darmstadt.de> asks why in CLISP
> (merge-pathnames (make-pathname :directory '(:relative "x"))
> (make-pathname :directory '(:relative "y")))
> => #"x/"
where he expects to get #"y/x/".
There are two reasons for this behaviour:
1. An informal one: I found the latter behaviour confusing and changed
CLISP to do it the former way. It seems to work better this way.
2. A formal one: MERGE-PATHNAMES is used to specify default components
for pathnames, so there is some analogy between (MERGE-PATHNAMES a b)
and (or a b). Obviously putting in the same default a second time
should do the same as putting it in once:
(or a b b) is the same as (or a b), so
(MERGE-PATHNAMES (MERGE-PATHNAMES a b) b) should be the same as
(MERGE-PATHNAMES a b).
(This question actually matters because in Common Lisp there is
no distinction between "pathnames with defaults merged-in" and
"pathnames with defaults not yet applied". For example, you don't
know whether COMPILE-FILE will merge in some defaults.)
Now, (MERGE-PATHNAMES (MERGE-PATHNAMES '#"x/" '#"y/") '#"y/")
and (MERGE-PATHNAMES '#"x/" '#"y/")
are equal in CLISP's implementation, but not in implementations
that strictly follow the Common Lisp spec. In fact, the above
twice-default = once-default rule holds for all pathnames in CLISP.
Bruno Haible email: <haible@ilog.fr>
Software Engineer phone: +33-1-49083585