[Rd] [WISH / PATCH] possibility to split string literals across multiple lines

Radford Neal radford at cs.toronto.edu
Fri Jun 16 20:04:25 CEST 2017

> On Wed, 14 Jun 2017, G?bor Cs?rdi wrote:
> > I like the idea of string literals, but the C/C++ way clearly does not
> > work. The Python/Julia way might, i.e.:
> >
> > """this is a
> > multi-line
> > lineral"""
> luke-tierney at uiowa.edu:

> This does look like a promising option; some more careful checking
> would be needed to make sure there aren't cases where currently
> working code would be broken.

I don't see how this proposal solves any problem of interest.

String literals can already be as long as you like.  The problem is
that they will get wrapped around in an editor (or not all be
visible), destroying the nice formatting of your program.

With the proposed extension, you can write long string literals with
short lines only if they were long only because they consisted of
multiple lines.  Getting a string literal that's 79 characters long
with no newlines (a perfectly good error message, for example) to fit
in your 80-character-wide editing window would still be impossible.

Furthermore, these Python-style literals have to have their second
and later lines start at the left edge, destroying the indentation
of your program (supposing you actually wanted to use one).

In contrast, C-style concatenation (by the parser) of consecutive
string literals works just fine for what you'd want to do in a
program.  The only thing they wouldn't do that the Python-style
literals would do is allow you to put big blocks of literal text in
your program, without having to put quotes around each line.  But
shouldn't such text really be stored in a separate file that gets
read, rather than in the program source?

   Radford Neal

More information about the R-devel mailing list