cl-rttemplate is a read-time quotation system. Published in the public domain. It’s a template system similar to the quasiquote & unquote facility, however, it operates during the read-time.
I’ve created this for a need to macroize the commonqt reader macros.
The asdf-installable package: cl-rttemplate.tar.gz
#"reader macro reads from the input until the sequence
"#is read. The character
#\"toggles quoting and the character
#\\is used for escaping.
#@reader macro is a helper which works like the splicing unquote
,@. Internally, it uses multiple values so if you have an unquoted form which returns multiple values, you can use
#n@to extract a single value,
ndenotes which value.
cl-rttemplate:*rt*is active during building the string representation which consists of writing of unquoted forms into strings.
enable-syntaxfunction enables the reader macros and copies the current
Enable the syntax by
Modify the readtable at your will; for example:
(setf (readtable-case rtt:*rt*) :preserve).
Simple symbol building:
#"'begin"(expt 3 8)"end"#
You can use the lexical bindings:
(let ((lexical-value '|Hello|)) #"'(a b " lexical-value " \"" lexical-value " world!\")"#)
and now change the
(setf (readtable-case rtt:*rt*) :preserve) (let ((lexical-value '|Hello|)) #"'(a b " lexical-value " \"" lexical-value " world!\")"#)
A splicing example:
#"'(a " #@'(a b c) " e)"#
and another one:
#"(* " #0@(floor 100 7) " " #1@(floor 25 13) ")"#