我有一个疑问,这是语言的本意吗,或者这是 Common Lisp 中的一种意外/不想要的行为/ BUG。
然而,我在 CLISP 和 SBCL 中都观察到了这一点:
我以为,
(make-pathname :directory (pathname-directory my-directory-path))
在所有操作系统中是/应该是互补的。
在 Linux 和 MacOS 中确实如此。
但在 Windows 中,您会丢失有关驱动器号的信息:
(pathname-directory #P"C:/Users/me/test/")
;;=> (:ABSOLUTE "Users" "me" "test") ;;=> Drive letter "c:" is lost!
然而,如果您使用~
,则可以保留它。
(pathname-directory #P"~/test/")
;;=> (:ABSOLUTE :HOME "test")
(make-pathname :directory (pathname-directory #P"~/test/"))
;;=> #P"~/test/" ;; no information loss!
(make-pathname :directory (pathname-directory #P"c:/Users/me/test/"))
;;=> #P"/Users/me/test/" ;;=> information loss - and not only that
;; it became an invalid path now, since the drive letter is lost!
这实际上不是语言规范中的一个错误吗?(因为 Windows 不存在或诸如此类?)。