unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* raw string literal reader extension
@ 2017-11-12 13:25 Daniel Llorens
  0 siblings, 0 replies; only message in thread
From: Daniel Llorens @ 2017-11-12 13:25 UTC (permalink / raw)
  To: guile-user


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-12 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 13:25 raw string literal reader extension Daniel Llorens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).