NIL and :UNSPECIFIC should be considered equivalent when comparing pathnames for equality
CMUCL consider nil
and :unspecific
to be different for the purposes of comparing pathnames. However, the standard suggests that pathnames that are considered functionally equivalent should compare equal
. This appears in the documentation for equal
which you can see here
http://www.lispworks.com/documentation/HyperSpec/Body/f_equal.htm
as well as in the following issue that introduced :unspecific
here
http://www.lispworks.com/documentation/HyperSpec/Issues/iss266_w.htm
At a very basic level, since nil
and :unspecified
have the same effect when converting a pathname to a namestring (neither is printed) they are functionally equivalent as far as the operating system is concerned.
That aside, the following example returns nil
in CMUCL but returns t
in ACL, CCL, and CLISP.
> (equal (make-pathname :name "foo" :type "txt" :device :unspecific) (make-pathname :name "foo" :type "txt" :device nil))
T
CLISP will not accept :unspecific
for the :type
argument but ACL and CCL will. On those two systems the following behavior can be observed
> (equal (make-pathname :name "foo" :type :unspecific) (make-pathname :name "foo" :type nil))
NIL
Perhaps this is not surprising since the example from the previously mentioned issue of (pathname-type (parse-namestring "foo"))
returns nil
and not :unspecific
. This furthermore implies there is some special logic used to ensure that for the :device
component nil
and :unspecific
compare equal.