Displaying 20 results from an estimated 10000 matches similar to: "[WISH / PATCH] possibility to split string literals across multiple lines"
2017 Jun 14
2
[WISH / PATCH] possibility to split string literals across multiple lines
I don't think it is reasonable to change the parser this way. This is
currently valid R code:
a <- "foo"
"bar"
and with the new syntax, it is also valid, but with a different
meaning. Or you can even consider
a <- "foo"
bar %>% func() %>% print()
etc.
I like the idea of string literals, but the C/C++ way clearly does not
work. The Python/Julia way
2017 Jun 16
0
[WISH / PATCH] possibility to split string literals across multiple lines
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:
2017 Jun 16
0
[WISH / PATCH] possibility to split string literals across multiple lines
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
>> >
2017 Jun 14
8
[WISH / PATCH] possibility to split string literals across multiple lines
Hi,
I would really like to have a way to split long string literals across
multiple lines in R.
Currently, if a string literal spans multiple lines, there is no way to
inhibit the introduction of newline characters:
> "aaa
+ bbb"
[1] "aaa\nbbb"
If a line ends with a backslash, it is just ignored:
> "aaa\
+ bbb"
[1] "aaa\nbbb"
We could use
2017 Jun 14
1
[WISH / PATCH] possibility to split string literals across multiple lines
On Wed, Jun 14, 2017 at 8:48 AM, Simon Urbanek
<simon.urbanek at r-project.org> wrote:
> As I recall this has been discussed at least a few times (unfortunately I'm traveling so can't check the references), but the justification was never satisfactory.
>
> Personally, I wouldn't mind string continuation supported since it makes for more readable code (I had one of my
2017 Jun 14
2
[WISH / PATCH] possibility to split string literals across multiple lines
Mark, that's actually a fair statement, although your extra operator
doesn't cause construction at parse time. You still call paste0(), but just
add an extra layer on top of it.
I also doubt that even in gigantic loops the benefit is going to be
significant. Take following example:
atestfun <- function(x){
y <- paste0("a very long",
"string for
2017 Jun 14
4
[WISH / PATCH] possibility to split string literals across multiple lines
On Wed, 14 Jun 2017 06:12:09 -0500, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 14/06/2017 5:58 AM, Andreas Kersting wrote:
> > Hi,
> >
> > I would really like to have a way to split long string literals across
> > multiple lines in R.
>
> I don't understand why you require the string to be a literal. Why not
> construct the long
2017 Jun 15
0
[WISH / PATCH] possibility to split string literals across multiple lines
On Wed, 14 Jun 2017, G?bor Cs?rdi wrote:
> I don't think it is reasonable to change the parser this way. This is
> currently valid R code:
>
> a <- "foo"
> "bar"
>
> and with the new syntax, it is also valid, but with a different
> meaning. Or you can even consider
>
> a <- "foo"
> bar %>% func() %>% print()
>
>
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
Having some line-breaking character for string literals would have benefits
as string literals can then be constructed parse-time rather than run-time.
I have run into this myself a few times as well. One way to at least
emulate something like that is the following.
`%+%` <- function(x,y) paste0(x,y)
"hello" %+%
" pretty" %+%
" world"
-Mark
Op wo 14 jun.
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
I know it doesn't cause construction at parse time, and it was also not
what I said. What I meant was that it makes the syntax at least look a
little as if you have a line-breaking character within string literals.
Op wo 14 jun. 2017 om 14:18 schreef Joris Meys <jorismeys at gmail.com>:
> Mark, that's actually a fair statement, although your extra operator
> doesn't cause
2015 Jun 18
1
Improving string concatenation
Gabor Csardi writes:
> Btw. for some motivation, here is a (surely incomplete) list of
> languages with '+' as the string concatenation operator:
>
> ALGOL 68, BASIC, C++, C#, Cobra, Pascal, Object Pascal, Eiffel, Go,
> JavaScript, Java, Python, Turing, Ruby, Windows Powers hell,
> Objective-C, F#, Sc-ala, Ya.
The situation for R is rather different from that of a
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
On 14/06/2017 6:45 AM, Andreas Kersting wrote:
> On Wed, 14 Jun 2017 06:12:09 -0500, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>
>> On 14/06/2017 5:58 AM, Andreas Kersting wrote:
>>> Hi,
>>>
>>> I would really like to have a way to split long string literals across
>>> multiple lines in R.
>>
>> I don't understand why
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
On 14/06/2017 5:58 AM, Andreas Kersting wrote:
> Hi,
>
> I would really like to have a way to split long string literals across
> multiple lines in R.
I don't understand why you require the string to be a literal. Why not
construct the long string in an expression like
paste0("aaa",
"bbb")
? Surely the execution time of the paste0 call is
2025 Jun 02
2
Specifying a long string literal across several lines
I suppose taste is learned as well. It does feel quite odd that the best
way to define a long string without a note or text wrapping is by being
creative with functions.
This is valid in Python, Julia, and Rust (if you add `let` and a
terminating semi-colon):
my_str = "part1\
part2\
part2"
I don't think it is abnormal to expect or desire this type of functionality
in our favorite
2025 Jun 02
1
Specifying a long string literal across several lines
Like Tomas, I find the paste0 readability to be **much** better, partly
because it allows for better indentation (as Tomas pointed out). Perhaps a
pointless email, but sometimes - for these subjective issues - it is
worthwhile to point out a difference in opinion.
Best,
Kasper
On Mon, Jun 2, 2025 at 12:27?PM Tomas Kalibera <tomas.kalibera at gmail.com>
wrote:
>
> On 6/2/25 17:37,
2025 Jun 02
2
Specifying a long string literal across several lines
One could also argue that paste0("a", "b", "c") is a function call
that needs to be evaluated at runtime, whereas "abc" is a string
constant understood by the parser, and often also language agnostic.
I'd assume compilers and code- and text-search tools do a better job
with the latter.
/Henrik
On Mon, Jun 2, 2025 at 2:18?PM Josiah Parry
2025 Jun 02
2
Specifying a long string literal across several lines
> On 3 Jun 2025, at 09:34, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:
>
> One could also argue that paste0("a", "b", "c") is a function call that needs to be evaluated at runtime, whereas "abc" is a string constant understood by the parser, and often also language agnostic. I'd assume compilers and code- and text-search tools
2025 Jun 02
1
Specifying a long string literal across several lines
On 6/2/25 17:37, Josiah Parry wrote:
> Tomas,
>
> Here is a good example of where this functionality would be useful:
> https://github.com/R-ArcGIS/arcgislayers/blob/2b29f4c254e7e5a1dadce8d4b0015a70dfae39d4/R/arc-open.R#L19-L56
>
> In order to prevent R CMD check notes I have to use `paste0()` to
> concatenate long URLs. If we were able to use `\` to
> separate the string
2025 Jun 02
1
Specifying a long string literal across several lines
Tomas,
Here is a good example of where this functionality would be useful:
https://github.com/R-ArcGIS/arcgislayers/blob/2b29f4c254e7e5a1dadce8d4b0015a70dfae39d4/R/arc-open.R#L19-L56
In order to prevent R CMD check notes I have to use `paste0()` to
concatenate long URLs. If we were able to use `\` to
separate the string across multiple lines, it would make the solution much
nicer!
On Mon, Jun
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
As I recall this has been discussed at least a few times (unfortunately I'm traveling so can't check the references), but the justification was never satisfactory.
Personally, I wouldn't mind string continuation supported since it makes for more readable code (I had one of my packages raise a NOTE in examples because there is no way in R to split a long hash into multiple lines), but