Re: [Rd] Generalised piping into operators

2023-04-22 Thread Michael Milton
This is all very intriguing. Normally when piping into an operator function, R throws "Error: function '+' not supported in RHS call of a pipe": > 1 |> `+`(2) Error: function '+' not supported in RHS call of a pipe This is a different error from the above "invalid use of pipe placeholder", which

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Dominick Samperi
A few years ago there was a post by the author of pipeR suggesting improvements in efficiency and reliability. Is there collaboration between these various pipe projects? Sent from my iPhone > On Apr 21, 2023, at 1:01 PM, Duncan Murdoch wrote: > > On 21/04/2023 12:16 p.m., Michael Milton wro

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Duncan Murdoch
On 21/04/2023 12:16 p.m., Michael Milton wrote: I'm afraid I don't understand. I know that parsing `+`(1, 1) returns a result equivalent to `1 + 1`, but why does that impose a restriction on parsing the pipe operator? What is the downside of allowing arbitrary RHS functions? I thought the dec

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Michael Milton
I'm afraid I don't understand. I know that parsing `+`(1, 1) returns a result equivalent to `1 + 1`, but why does that impose a restriction on parsing the pipe operator? What is the downside of allowing arbitrary RHS functions? [[alternative HTML version deleted]]

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Duncan Murdoch
On 21/04/2023 11:33 a.m., Michael Milton wrote: Thanks, this makes sense. Is there a similar precedence reasoning behind why operator functions (`+` etc) can't be piped into? Yes: > identical(quote(1 + 1), quote(`+`(1, 1))) [1] TRUE Duncan Murdoch

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Michael Milton
Thanks, this makes sense. Is there a similar precedence reasoning behind why operator functions (`+` etc) can't be piped into? On Fri, Apr 21, 2023 at 11:52 PM Duncan Murdoch wrote: > On 21/04/2023 4:35 a.m., Michael Milton wrote: > > I just checked out R-devel and noticed that the new "pipe ext

Re: [Rd] Generalised piping into operators

2023-04-21 Thread Duncan Murdoch
On 21/04/2023 4:35 a.m., Michael Milton wrote: I just checked out R-devel and noticed that the new "pipe extractor" capability coming in 4.3 only works for the 4 extractor operators, but no other standard operators like +, *, %*% etc, meaning that e.g. mtcars |> as.matrix() |> _ + 1 |> colMeans()

[Rd] Generalised piping into operators

2023-04-21 Thread Michael Milton
I just checked out R-devel and noticed that the new "pipe extractor" capability coming in 4.3 only works for the 4 extractor operators, but no other standard operators like +, *, %*% etc, meaning that e.g. mtcars |> as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are still sub