Re: [Rd] Warning with new placeholder piped to data.frame extractors `[` and `[[`.

2022-07-18 Thread Duncan Murdoch

The code from gram.y that handles this looks like this in R-devel:

/* allow top-level placeholder */
for (SEXP a = CDR(rhs); a != R_NilValue; a = CDR(a))
if (CAR(a) == R_PlaceholderToken) {
if (TAG(a) == R_NilValue)
raiseParseError("placeholderNotNamed", rhs,
NO_VALUE, NULL, lloc_rhs,
_("pipe placeholder can only be used as a 
named argument (%s:%d:%d)"));

checkTooManyPlaceholders(rhs, CDR(a), lloc_rhs);
SETCAR(a, lhs);
return rhs;
}

check_rhs(rhs, lloc_rhs);

The "check_rhs" function is the one that complains about using `[` as a 
function on the right hand side.  So it is never run when there's a 
placeholder found.  Not sure if this is intentional or not.


You can see more context here: 
https://github.com/wch/r-source/blob/0ece3677bc1c4a1c76ecbcff62424d72d742d492/src/main/gram.y#L1248 
.


Duncan Murdoch



On 18/07/2022 3:48 p.m., Gabriel Becker wrote:

It looks to me like the 'bug' here seems to be that

aggregate(y ~ f, df1, mean) |> `[`(x = _, 'y')


does not throw the same error as

aggregate(y ~ f, df1, mean) |> `[`('y')


Since the latter seems pretty clear that the intent is that `[` is
disallowed on the RHS of the pipe by design.

~G


On Mon, Jul 18, 2022 at 11:07 AM Toby Hocking  wrote:


Is the intent is to encourage the user to do something simpler like...
aggregate(y ~ f, df1, mean)$y
aggregate(y ~ f, df1, mean)["y"]
aggregate(y ~ f, df1, mean)[["y"]]
??

On Sat, Jul 16, 2022 at 8:27 AM Rui Barradas  wrote:


Hello,

When piping to any of `[.data.frame` or `[[.data.frame`, the placeholder
in mandatory.


df1 <- data.frame(y = 1:10, f = rep(c("a", "b"), each = 5))

aggregate(y ~ f, df1, mean) |> `[`('y')
# Error: function '[' not supported in RHS call of a pipe

aggregate(y ~ f, df1, mean) |> `[[`('y')
# Error: function '[' not supported in RHS call of a pipe



But if used it throws a warning.



aggregate(y ~ f, df1, mean) |> `[`(x = _, 'y')
#  Warning in `[.data.frame`(x = aggregate(y ~ f, df1, mean), "y"):
named arguments
#  other than 'drop' are discouraged
#y
#  1 3
#  2 8

aggregate(y ~ f, df1, mean) |> `[[`(x = _, 'y')
#  Warning in `[[.data.frame`(x = aggregate(y ~ f, df1, mean), "y"):

named

#  arguments other than 'exact' are discouraged
#  [1] 3 8



Hasn't this become inconsistent behavior?
More than merely right, the named argument is mandatory, it shouldn't
give warnings.

Hope this helps,

Rui Barradas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



 [[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R-Devel (82603) still passing "fno-optimize-sibling-calls" on Windows

2022-07-18 Thread Tomas Kalibera



On 7/18/22 19:14, Avraham Adler wrote:

Hello.

According to my understanding of the changes in R-devel, the flag
-fno-optimize-sibling-calls should no longer be forced when compiling
R. Yet, as I compile R, revision 82603, from source on Windows
(Skylake-X server) I see the flag being passed (example below). Is
this different for Windows than for Unix? The changes header seems to
be its own and not under the "Installation on Unix-Alike" header.

Thank you,

Avi


Hi Avi,

yes, thanks for reminding me, I will remove that in the Windows make 
files (in about a week or so). There is no need to be more careful on 
Windows than Unix regarding this (actually a bit on the contrary, as 
most users use the same compiler). Feel free to remove that already in 
your builds.


Tomas


Excerpt:
making Lapack.d from Lapack.c
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin -ffloat-store -c dlamch.f -o
dlamch.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c dlapack.f -o dlapack.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c cmplx.f -o cmplx.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c la_constants.f90 -o
la_constants.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c dlartg.f90 -o dlartg.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c la_xisnan.f90 -o la_xisnan.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c dlassq.f90 -o dlassq.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c zlartg.f90 -o zlartg.o
gfortran  -O3 -march=native -pipe -fno-optimize-sibling-calls -flto
-ffat-lto-objects -fuse-linker-plugin  -c zlassq.f90 -o zlassq.o

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel