From murdoch.duncan at gmail.com  Fri Jun 16 21:17:10 2017
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Fri, 16 Jun 2017 15:17:10 -0400
Subject: [Rd] [WISH / PATCH] possibility to split string literals across
 multiple lines
In-Reply-To: <20170616180425.GA24745@mail.cs.toronto.edu>
References: <mailman.5.1497607202.2257.r-devel@r-project.org>
 <20170616180425.GA24745@mail.cs.toronto.edu>
Message-ID: <f9fe4bb1-d2b4-895e-ceb1-5497c197c3f2@gmail.com>

On 16/06/2017 2:04 PM, Radford Neal wrote:
>> 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?

I agree with most of this, but I still don't see the need for a syntax 
change.  That's a lot of work just to avoid typing "paste0" and some 
commas in

  paste0("this is the first part",
         "this is the second part")

If the rather insignificant amount of time it takes to execute this 
function call really matters (and I'm not convinced of that), then 
shouldn't it be solved by the compiler applying constant folding to 
paste0()?

(Some syntax like r"xyz" to make it easier to type strings containing 
backslashes and quotes would actually be useful, but that's a different 
issue.)

Duncan Murdoch



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