Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread avi.e.gross
Have we talked this topic out yet? As has been mentioned, R allows many strategies with perhaps the simplest being to use the paste functions. Here, is a not simpler version where you do a global substitution that removes it alongside the artificial newlines. gsub(pattern="\n", replacement

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Kevin Ushey
I also suspect the byte compiler could constant-fold some of these common paste expressions, effectively negating any potential runtime cost of `paste` / `paste0` with string literals. Beyond the syntax restrictions for automatic concatenation of sequential string literals, it's also a big footgun

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread avi.e.gross
Henrik, As R is an interpreted language and paste0 is likely a nice and fast built-in function likely already written in some version of C, there does not seem much room for a speedup as everything is done at run time. The parser phase may indeed have abilities to simplify but often at the expe

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Simon Urbanek
> On 3 Jun 2025, at 09:34, Henrik Bengtsson 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-

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread avi.e.gross
My two cents (soon to be discontinued) is that it is not very relevant to compare one computer language ALREADY DESIGNED to another and insist they become the same. Next we will be asked to allow "+" or just adjacency to connect two or more quoted strings because, well, Python does that. Then, w

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Henrik Bengtsson
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

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Josiah Parry
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

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Kasper Daniel Hansen
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

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Tomas Kalibera
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 concat

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Josiah Parry
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 `\

Re: [Rd] Bug in prettyNum

2025-06-02 Thread Marttila Mikko via R-devel
Hi, Thanks, Ivan, for the additional diagnosis and debugging tips. Thanks, Martin, for the prompt fix. Thanks, Toby, for sharing the R Dev Container link. I tried it out and was able to easily test some changes. I'll be using that in the future! Best, Mikko -Original Message- From: R

Re: [Rd] Specifying a long string literal across several lines

2025-06-02 Thread Tomas Kalibera
On 5/28/25 04:15, Pavel Krivitsky via R-devel wrote: Dear All, Perhaps this should go in r-package-devel, but I suspect that this is going to turn into a feature request, and I want to run it by the list before filing it in the Bugzilla. I would like to specify a long string literal without m