Escaping a double quote in Common Lisp

How to avoid double quotes when concatenating a string? For example, I was hoping that

(concatenate 'string "Mama said: " "\"Son, your life is an open book...\"") 

:

 "Mama said: "Son, your life is an open book..."" 

but instead returned it using backslashes like:

 "Mama said: \"Son, your life is an open book...\"" 
+4
source share
1 answer

The return value is printed readily, that is, using a view that can be parsed using READ into the CL object. If you use a function like PRINC that prints the string as is, you will see that the quote did what you wanted (the external quotation marks are not part of the string):

 CL-USER> (princ (concatenate 'string "Mama said: " "\"Son, your life is an open book...\"")) Mama said: "Son, your life is an open book..." "Mama said: \"Son, your life is an open book...\"" 

The first line is the result of PRINC, the second part of the PRINT part of the READ-EVAL-PRINT-LOOP.

+11
source

Source: https://habr.com/ru/post/1401425/


All Articles