如何将双引号符号转换为字符串

问题描述

我知道如何将符号转换为字符串:public bool Delete(string Id) { try { var a = Get(Id); if (a == null) { return false; } dbContext.SystemMessage.Remove(a); dbContext.SaveChanges(); return true; } catch (Exception e) { logger.LogError(e,"Failed to delete System Message" + " - " + e.Message); return false; } } (symbol-name 'hello) 返回 (string 'hello)。如果符号被引用两次怎么办?例如:"Hello"''hello 导致错误。在 SBCL 中,错误消息是:(string ''hello)。如何将 'HELLO is not a string designator. 转换为 ''hello

解决方法

只需在 REPL 中检查数据的样子即可。 * 是绑定到最后一个评估结果的变量。

CL-USER 1 > 'hello
HELLO

CL-USER 2 > (string *)
"HELLO"

CL-USER 3 > ''hello
(QUOTE HELLO)

CL-USER 4 > (string (second *))
"HELLO"
,

由于 ''hello 等价于 (quote (quote hello)),您可以:

CL-USER> (string (cadr ''hello))
"HELLO"

您还可以使用 eval 来评估外部 quote

CL-USER> (string (eval ''hello))
"HELLO"