cl-heredoc is an implementation of "here documents" that allow the user to embed literal strings into code or data without any need for quoting, something that is missing in both ANSI CL and popular implementations.

cl-heredoc primarily exports a single function, READ-HEREDOC, that is meant to be used with the CL reader by attaching it to a dispatch character, e.g.

CL-USER> (set-dispatch-macro-character #\# #\> #'cl-heredoc:read-heredoc)
CL-USER> #>eof>Write whatever (you) "want",
  no matter how many lines or what characters until
the magic end sequence has been reached!eof

Will read everything starting after "#>eof>" until the given sequence, here "eof", is found and return the result as a string. The enclosed text is not subject to any kind of evaluation and needs no quoting. If used in a non-interactive fashion, i.e. outside the REPL, an error will be signaled if EOF is reached.

The underlying implementation uses ring buffers as described by Paul Graham in "ANSI Common Lisp" so partial end sequence matches will not prevent an immediately following real match that re-uses part of the discarded one.

Categories: development, text
Author: Alexander Kahl

The package is asdf-installable. The link to the git repository is available from Github.

ASDF-install package (obsolete)