common-lisp - 打印原始路径名结构

标签 common-lisp

使用 CCL,当我使用例如 (format t "~s" pathname) 打印路径名时,或与 pprint ,或与 print ,它会打印出 #P读者语法。例如:

? (make-pathname :directory "foo")
#P"foo/"
? (format t "~s" (make-pathname :directory "foo"))
#P"foo/"
NIL

我真的很想看到底层的路径名结构,这样我就可以准确地说出对象的样子。有没有办法原始打印?

最佳答案

我不知道这是否是您要找的,但您可以 call the inspector

(inspect thing)

覆铜板示例:
? (inspect (make-pathname :directory "foo"))
[0]     #P"foo/"
[1]     Type: PATHNAME
[2]     Class: #<BUILT-IN-CLASS PATHNAME>
[3]     TYPE: (PATHNAME . #<CCL::CLASS-WRAPPER PATHNAME #x14083886>)
[4]     %PATHNAME-DIRECTORY: (:RELATIVE "foo")
[5]     %PATHNAME-NAME: NIL
[6]     %PATHNAME-TYPE: NIL
[7]     %PHYSICAL-PATHNAME-VERSION: NIL
[8]     %PHYSICAL-PATHNAME-DEVICE: NIL
Inspect> help
The following toplevel commands are available:
 <n>    the same as (:I <n>)
 (:S N V)  set the <n>th line of object data to value <v>
 :HOME   show first page of object data
 :PREV   show previous page of object data
 :NEXT   show next page of object data
 :SHOW   re-show currently inspected object (the value of CCL:@)
 :Q     exit inspector
 :POP   exit current inspector level
 (:I N)  inspect <n>th item
 :?     help
 :PWD   Print the pathame of the current directory
 (:CD DIR)  Change to directory DIR (e.g., #p"ccl:" or "/some/dir")
 (:PROC &OPTIONAL P)  Show information about specified process <p>/all processes
 (:KILL P)  Kill process whose name or ID matches <p>
 (:Y &OPTIONAL P)  Yield control of terminal-input to process
whose name or ID matches <p>, or to any process if <p> is null
Any other form is evaluated and its results are printed out.
Inspect> 

Example on ideone with CLISP

关于common-lisp - 打印原始路径名结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39392510/

相关文章:

emacs - Clip + Emacs 编译和加载文件

lambda - 这个 lambda 在 common lisp 中如何获取它的函数参数?

emacs - SLIME who-用 'nesting exceeds max-lisp-eval-depth' 报错

bitmap - - LISP - 如何通过脚本创建位图文件?

json - 在 lisp 中输入/输出 json 文件

lisp - 我不知道这个功能应该做什么

package - Clisp 找不到包

lisp - 使用带有 Common Lisp 的排序的意外列表重复

common-lisp - 如何将列表传递给 cl-mustache?

linux - 在 lisp 上使用 dolist 从列表中提取 n 元素