Indentation and line breaks in string literals

Kevin Reid <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
? e`{"abc\ndef"}`
# value: e`{
#            "abc
#            def"
#        }`

? e`{
 >     "abc
 >     def"
 > }`
# value: e`{
#            "abc
#                def"
#        }`

As the above demonstrates, the E parser and printer fail to be  
consistent when given a string literal containing a line break.

For this reason, and for use of multi-line quasiliterals in ordinary  
source, it seems to me that there ought to be a notation for ignoring  
indentation whitespace in string and quasi-literals.

What should this be?

Some prior art I know of:

In Common Lisp format strings, a ~ followed by a newline ignores that  
newline and any following whitespace, with options to not ignore  
either one:
http://www.lispworks.com/documentation/HyperSpec/Body/22_cic.htm

   (format nil "foo~
                bar")
=> foobar

   (format nil "foo~@
                bar")
=> foo
=> bar

In Haskell, whitespace surrounded by \ is ignored. This allows for  
leading whitespace to be specified in continuation lines.
http://www.haskell.org/onlinereport/lexemes.html#sect2.6

   "{\n\
   \  foo\n\
   \  bar\n\
   \}"

=> {
=>   foo
=>   bar
=> }

Then there are the languages (C?) which allow adjacent string  
literals and consider them concatenated:

   "foo\n"
   "  bar"

=> foo
=>   bar

(This has the advantage of not introducing additional escape-ish  
syntax, but using it in E would require extra backslashes to prohibit  
statement termination, and the quasiliteral form of the preceding  
example would look funny:
   quasiname`foo$\n` \
            `  bar`
)

Your opinions?

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.