(please be gentle, it's my first time)
I am interested in discussions (possibly reiterating past threads --
searching didn't turn up much) on the possibility of supporting standard
evaluation unquoting at the language level. This has been brought up in a
recent similar thread here [1] and on Twitt
I don't have a positive or negative opinion on this yet, but I do have a
question. If I define both unary and binary operators with the same
name (in different frames, presumably), what would happen?
Is "a %chr% b" a syntax error if unary %chr% is found first? If both
might be found, does "a
I am biased against introducing new syntax, but if one is
experimenting with it one should make sure the precedence feels right.
I think the unary and binary minus-sign operators have different
precedences so I see no a priori reason to make the unary and binary
%xxx% operators to be the same.
Bill
I guess this would establish a separate "namespace" of symbolic prefix
operators, %*% being an example in the infix case. So you could have stuff
like %?%, but for non-symbolic (spelled out stuff like %foo%), it's hard to
see the advantage vs. foo(x).
Those examples you mention should probably be
I used the `function(x)` form to explicitly show the function was
being called with only one argument, clearly performance implications
are not relevant for these examples.
I think of this mainly as a gap in the tooling we provide users and
package authors. R has native prefix `+1`, functional `f(
Martin,
Jim can speak directly to his motivations; I don't claim to be able to do
so. That said, I suspect this is related to a conversation on twitter about
wanting an infix "unquote" operator in the context of the non-standard
evaluation framework Hadley Wickham and Lionel Henry (and possibly ot
> Jim Hester
> on Thu, 16 Mar 2017 12:31:56 -0400 writes:
> Gabe,
> The unary functions have the same precedence as normal SPECIALS
> (although the new unary forms take precedence over binary SPECIALS).
> So they are lower precedence than unary + and -. Yes, both of yo
Gabe,
The unary functions have the same precedence as normal SPECIALS
(although the new unary forms take precedence over binary SPECIALS).
So they are lower precedence than unary + and -. Yes, both of your
examples are valid with this patch, here are the results and quoted
forms to see the precede
Jim,
This seems cool. Thanks for proposing it. To be concrete, he user-defined
unary operations would be of the same precedence (or just slightly below?)
built-in unary ones? So
"100" %identical% %chr% 100
would work and return TRUE under your patch?
And with %num% <- as.numeric, then
1 + - %
R has long supported user defined binary (infix) functions, defined
with `%fun%`. A one line change [1] to R's grammar allows users to
define unary (prefix) functions in the same manner.
`%chr%` <- function(x) as.character(x)
`%identical%` <- function(x, y) identical(x, y)
%chr% 100
10 matches
Mail list logo