Created
June 27, 2011 13:59
-
-
Save danlei/1048903 to your computer and use it in GitHub Desktop.
Simple raw string reader macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Beware: #" is actually not reserved for the user. See: | |
;; http://www.lispworks.com/documentation/HyperSpec/Body/02_dh.htm | |
(defun read-raw-string (stream subchar arg) | |
(declare (ignore subchar arg)) | |
(with-output-to-string (out) | |
(loop for char = (read-char stream nil nil) | |
while (and char (char/= char #\")) | |
do (write-char char out)))) | |
(set-dispatch-macro-character #\# #\" #'read-raw-string) | |
;; CL-USER> #"\<foo\>" | |
;; "\\<foo\\>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment