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

Hadley Wickham h.wickham at gmail.com
Fri Jun 16 21:10:20 CEST 2017


On Fri, Jun 16, 2017 at 1:14 PM, Gábor Csárdi <csardi.gabor at gmail.com> wrote:
> On Fri, Jun 16, 2017 at 7:04 PM, Radford Neal <radford at cs.toronto.edu> 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.
>
> From the Python docs:
>
> String literals can span multiple lines. One way is using
> triple-quotes: """...""" or '''...'''. End of lines are automatically
> included in the string, but it’s possible to prevent this by adding a
> \ at the end of the line.

And additionally, in Julia triple quoted strings:

Trailing whitespace is left unaltered. They can contain " symbols
without escaping. Triple-quoted strings are also dedented to the level
of the least-indented line. This is useful for defining strings within
code that is indented. For example:

Hadley

-- 
http://hadley.nz



More information about the R-devel mailing list