使用 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/