Re: [Rd] order of operations

2021-08-27 Thread Duncan Murdoch
On 27/08/2021 3:06 p.m., Enrico Schumann wrote: On Fri, 27 Aug 2021, Gabor Grothendieck writes: Are there any guarantees of whether x will equal 1 or 2 after this is run? (x <- 1) * (x <- 2) ## [1] 2 x ## [1] 2 At least the "R Language Definition" [1] says "The exponentiation operator ‘^

Re: [Rd] order of operations

2021-08-27 Thread Enrico Schumann
On Fri, 27 Aug 2021, Gabor Grothendieck writes: > Are there any guarantees of whether x will equal 1 or 2 after this is run? > > (x <- 1) * (x <- 2) > ## [1] 2 > x > ## [1] 2 At least the "R Language Definition" [1] says "The exponentiation operator ‘^’ and the left assignment plus minus op

Re: [Rd] order of operations

2021-08-27 Thread GILLIBERT, Andre
Due to lazy evaluation, the order of operations can be pretty random in R. Actually, some operations may not be performed at all, sometimes. The following program illustrates the issue: test1=function(x,y) {} test2=function(x,y) {x;y} test3=function(x,y) {y;x} alpha="hello" test1(alpha <- 1, al

Re: [Rd] order of operations

2021-08-27 Thread Avi Gross via R-devel
Running things in various forms of parallel opens up all kinds of issues. Currently, programs that use forms like "threads" often need to carefully protect any variables that can be changed using things like locks. So what would they do in the scenario being discussed? Would they need to analyz

Re: [Rd] order of operations

2021-08-27 Thread Gabor Grothendieck
It could be that the two sides of * are run in parallel in the future and maybe not having a guarantee would simplify implementation? On Fri, Aug 27, 2021 at 12:35 PM Avi Gross via R-devel wrote: > > Does anyone have a case where this construct has a valid use? > > Didn't Python add a := operat

Re: [Rd] order of operations

2021-08-27 Thread Avi Gross via R-devel
Does anyone have a case where this construct has a valid use? Didn't Python add a := operator recently that might be intended more for such uses as compared to using the standard assignment operators? I wonder if that has explicit guarantees of what happens in such cases, but that is outside wha

Re: [Rd] order of operations

2021-08-27 Thread Gabor Grothendieck
I agree and personally never do this but I would still like to know if it is guaranteed behavior or not. On Fri, Aug 27, 2021 at 11:28 AM Thierry Onkelinx wrote: > IMHO this is just bad practice. Whether the result is guaranteed or not, > doesn't matter. > > ir. Thierry Onkelinx > Statisticus /

Re: [Rd] order of operations

2021-08-27 Thread Thierry Onkelinx via R-devel
IMHO this is just bad practice. Whether the result is guaranteed or not, doesn't matter. ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Te

[Rd] order of operations

2021-08-27 Thread Gabor Grothendieck
Are there any guarantees of whether x will equal 1 or 2 after this is run? (x <- 1) * (x <- 2) ## [1] 2 x ## [1] 2 -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-devel@r-p

[Rd] R_CheckUserInterrupt

2021-08-27 Thread GILLIBERT, Andre
Dear R developers, R makes some functions interruptible, thanks to a call to R_CheckUserInterrupt. Simple arithmetic operations can be interrupted avoiding freezes when using huge arrays (e.g. length > 1 billion). But many operations, such as matrix multiplication, are not interruptible. I es