Skip to content

Instantly share code, notes, and snippets.

@danlei
Created June 27, 2011 13:59
Show Gist options
  • Save danlei/1048903 to your computer and use it in GitHub Desktop.
Save danlei/1048903 to your computer and use it in GitHub Desktop.
Simple raw string reader macro
;; 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