引用用管道包围它的输出 - 为什么?

Quoting surrounds its output with pipes - why?

我创建了一个 table daily-planet 如下:

(setf daily-planet '((olsen jimmy 123-76-4535 cub-reporter)
                     (kent  clark 089-52-6787 reporter)
                     (lane  lois  951-26-1438 reporter)
                     (white perry 355-16-7439 editor)))

现在想通过运行宁mapcar提取社保号如下:

(mapcar #'caddr daily-planet)

结果是:

(|123-76-4535| |089-52-6787| |951-26-1438| |355-16-7439|)

我本以为:

(123-76-4535 089-52-6787 951-26-1438 355-16-7439)

当我尝试运行更简单

'(123-456)

我看到它也被评估为:

(|123-456|)

为什么?

与评价无关

CL-USER 84 > '123-456-789
|123-456-789|

CL-USER 85 > (type-of '123-456-789)
SYMBOL

123-456-789是一个符号。打印机可能会将其打印为 |123-456-789|. 原因:它的名称中只有数字和 - 字符,这使得打印的表示形式成为所谓的 潜在数字 .

管道字符是符号的转义字符。它包围着符号字符串,这将是符号名称。

CL-USER 86 > '|This is a strange symbol with digits, spaces and other characters --- !!!|
|This is a strange symbol with digits, spaces and other characters --- !!!|

CL-USER 87 > (symbol-name *)
"This is a strange symbol with digits, spaces and other characters --- !!!"

出于某种原因,打印机可能认为 123-456-789 应该被转义打印。但符号名称相同:

CL-USER 88 > (eq '123-456 '|123-456|)
T

转义允许符号具有任意名称。

一个没用的例子:

CL-USER 89 > (defun |Gravitation nach Einstein| (|Masse in kg|) (list |Masse in kg|))
|Gravitation nach Einstein|

CL-USER 90 > (|Gravitation nach Einstein| 10)
(10)

反斜杠是单个转义符(默认情况下字符会大写):

CL-USER 93 > 'foo\foo\ bar
|FOOfOO BAR|

旁注:

Common Lisp 有潜在数字 的想法。有各种数字类型的数字语法:整数、浮点数、比率、复数……但标准定义了扩展空间。例如 123-456-789 在扩展的 Common Lisp 中可能是一个数字!当打印机看到一个看起来可能是潜在数字的符号时,它会对该符号进行转义,以便它可以安全地作为符号读回...