[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
raw string literal reader extension
From: |
Daniel Llorens |
Subject: |
raw string literal reader extension |
Date: |
Sun, 12 Nov 2017 14:25:58 +0100 |
Hi,
https://github.com/lloda/guile-raw-strings
is a reader extension to be able to write string literals verbatim, without
escapes. E.g. you can write
#R-(quotes " and escapes \ and newlines
can " freely be used " here)-
where you'd normally need escapes:
"quotes \" and escapes \\ and newlines\n can \" freely be used \"
here"
This comes in handy for docstrings, regexps, etc.
The delimiters are arbitrary strings (so - above). I took this from one of the
varieties of C++ raw string literals [variant (6) in
http://en.cppreference.com/w/cpp/language/string_literal] as it seems to be the
most flexible take. In other variants the delimiters are fixed, so one would
still need to escape certain characters.
On the Scheme/Lisp side I'm not aware of anything standard, but a quick search
shows stuff like
http://mihai.bazon.net/blog/hashes-and-raw-strings-in-common-lisp or
https://github.com/cmpitg/racket-raw-string, where the delimiters are either
single characters or certain delimiter pairs. It's trivial to modify the
present extension to work in that way.
Anyway, I hope some of you can find this useful.
Regards
Daniel
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- raw string literal reader extension,
Daniel Llorens <=