Re: [Rd] `[` not recognized as a primitive in certain cases.
> Joris Meys> on Tue, 28 Mar 2017 15:19:14 +0200 writes: > Thank you gents, I overlooked the subtle differences. > On Tue, Mar 28, 2017 at 2:49 PM, Lukas Stadler > wrote: >> “typeof” is your friend here: >> >> > typeof(`[`) >> [1] "special" >> > typeof(mc[[1]]) >> [1] "symbol" >> > typeof(mc2[[1]]) >> [1] "special" >> >> so mc[[1]] is a symbol, and thus not a primitive. or str() which should be better known to Joe Average useR > mc <- call("[",iris,2,"Species") > str(mc[[1]]) symbol [ > str(`[`) .Primitive("[") > >> - Lukas >> >> > On 28 Mar 2017, at 14:46, Michael Lawrence >> wrote: >> > >> > There is a difference between the symbol and the function (primitive >> > or closure) to which it is bound. >> > >> > This: >> > mc2 <- as.call(list(`[`,iris,2,"Species")) >> > >> > Evaluates `[` to its value, in this case the primitive object, and the >> > primitive itself is incorporated into the returned call. >> > >> > If you were to do this: >> > mc2 <- as.call(list(quote(`[`),iris,2,"Species")) >> > >> > The `[` would _not_ be evaluated, quote() would return the symbol, and >> > the symbol would end up in the call. >> > >> > The two forms have virtually identical behavior as long as the call >> > ends up getting evaluated in the same environment. >> > >> > On Tue, Mar 28, 2017 at 3:03 AM, Joris Meys wrote: >> >> Dear, >> >> >> >> I have noticed this problem while looking at the following question on >> >> Stackoverflow : >> >> >> >> http://stackoverflow.com/questions/42894213/s4-class- >> subset-inheritance-with-additional-arguments >> >> >> >> While going through callNextMethod, I've noticed the following odd >> >> behaviour: >> >> >> >> mc <- call("[",iris,2,"Species") >> >> >> >> mc[[1]] >> >> ## `[` >> >> >> >> is.primitive(`[`) >> >> ## [1] TRUE >> >> >> >> is.primitive(mc[[1]]) >> >> ## [1] FALSE >> >> # Expected to be TRUE >> >> >> >> mc2 <- as.call(list(`[`,iris,2,"Species")) >> >> >> >> is.primitive(mc2[[1]]) >> >> ## [1] TRUE >> >> >> >> So depending on how I construct the call (using call() or as.call() ), >> the >> >> function `[` is or is not recognized as a primitive by is.primitive() >> >> >> >> The behaviour is counterintuitive and -unless I miss something obvious >> >> here- likely to be a bug imho. I immediately admit that my C chops >> aren't >> >> sufficient to come up with a patch. >> >> >> >> Cheers >> >> Joris >> >> >> >> -- >> >> Joris Meys >> >> Statistical consultant >> >> >> >> Ghent University >> >> Faculty of Bioscience Engineering >> >> Department of Mathematical Modelling, Statistics and Bio-Informatics >> >> >> >> tel : +32 (0)9 264 61 79 >> >> joris.m...@ugent.be >> >> --- >> >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php >> >> >> >>[[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 >> >> > -- > Joris Meys > Statistical consultant > Ghent University > Faculty of Bioscience Engineering > Department of Mathematical Modelling, Statistics and Bio-Informatics > tel : +32 (0)9 264 61 79 > joris.m...@ugent.be > --- > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > [[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] `[` not recognized as a primitive in certain cases.
Thank you gents, I overlooked the subtle differences. On Tue, Mar 28, 2017 at 2:49 PM, Lukas Stadlerwrote: > “typeof” is your friend here: > > > typeof(`[`) > [1] "special" > > typeof(mc[[1]]) > [1] "symbol" > > typeof(mc2[[1]]) > [1] "special" > > so mc[[1]] is a symbol, and thus not a primitive. > > - Lukas > > > On 28 Mar 2017, at 14:46, Michael Lawrence > wrote: > > > > There is a difference between the symbol and the function (primitive > > or closure) to which it is bound. > > > > This: > > mc2 <- as.call(list(`[`,iris,2,"Species")) > > > > Evaluates `[` to its value, in this case the primitive object, and the > > primitive itself is incorporated into the returned call. > > > > If you were to do this: > > mc2 <- as.call(list(quote(`[`),iris,2,"Species")) > > > > The `[` would _not_ be evaluated, quote() would return the symbol, and > > the symbol would end up in the call. > > > > The two forms have virtually identical behavior as long as the call > > ends up getting evaluated in the same environment. > > > > On Tue, Mar 28, 2017 at 3:03 AM, Joris Meys wrote: > >> Dear, > >> > >> I have noticed this problem while looking at the following question on > >> Stackoverflow : > >> > >> http://stackoverflow.com/questions/42894213/s4-class- > subset-inheritance-with-additional-arguments > >> > >> While going through callNextMethod, I've noticed the following odd > >> behaviour: > >> > >> mc <- call("[",iris,2,"Species") > >> > >> mc[[1]] > >> ## `[` > >> > >> is.primitive(`[`) > >> ## [1] TRUE > >> > >> is.primitive(mc[[1]]) > >> ## [1] FALSE > >> # Expected to be TRUE > >> > >> mc2 <- as.call(list(`[`,iris,2,"Species")) > >> > >> is.primitive(mc2[[1]]) > >> ## [1] TRUE > >> > >> So depending on how I construct the call (using call() or as.call() ), > the > >> function `[` is or is not recognized as a primitive by is.primitive() > >> > >> The behaviour is counterintuitive and -unless I miss something obvious > >> here- likely to be a bug imho. I immediately admit that my C chops > aren't > >> sufficient to come up with a patch. > >> > >> Cheers > >> Joris > >> > >> -- > >> Joris Meys > >> Statistical consultant > >> > >> Ghent University > >> Faculty of Bioscience Engineering > >> Department of Mathematical Modelling, Statistics and Bio-Informatics > >> > >> tel : +32 (0)9 264 61 79 > >> joris.m...@ugent.be > >> --- > >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > >> > >>[[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 > > -- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Mathematical Modelling, Statistics and Bio-Informatics tel : +32 (0)9 264 61 79 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] `[` not recognized as a primitive in certain cases.
“typeof” is your friend here: > typeof(`[`) [1] "special" > typeof(mc[[1]]) [1] "symbol" > typeof(mc2[[1]]) [1] "special" so mc[[1]] is a symbol, and thus not a primitive. - Lukas > On 28 Mar 2017, at 14:46, Michael Lawrencewrote: > > There is a difference between the symbol and the function (primitive > or closure) to which it is bound. > > This: > mc2 <- as.call(list(`[`,iris,2,"Species")) > > Evaluates `[` to its value, in this case the primitive object, and the > primitive itself is incorporated into the returned call. > > If you were to do this: > mc2 <- as.call(list(quote(`[`),iris,2,"Species")) > > The `[` would _not_ be evaluated, quote() would return the symbol, and > the symbol would end up in the call. > > The two forms have virtually identical behavior as long as the call > ends up getting evaluated in the same environment. > > On Tue, Mar 28, 2017 at 3:03 AM, Joris Meys wrote: >> Dear, >> >> I have noticed this problem while looking at the following question on >> Stackoverflow : >> >> http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments >> >> While going through callNextMethod, I've noticed the following odd >> behaviour: >> >> mc <- call("[",iris,2,"Species") >> >> mc[[1]] >> ## `[` >> >> is.primitive(`[`) >> ## [1] TRUE >> >> is.primitive(mc[[1]]) >> ## [1] FALSE >> # Expected to be TRUE >> >> mc2 <- as.call(list(`[`,iris,2,"Species")) >> >> is.primitive(mc2[[1]]) >> ## [1] TRUE >> >> So depending on how I construct the call (using call() or as.call() ), the >> function `[` is or is not recognized as a primitive by is.primitive() >> >> The behaviour is counterintuitive and -unless I miss something obvious >> here- likely to be a bug imho. I immediately admit that my C chops aren't >> sufficient to come up with a patch. >> >> Cheers >> Joris >> >> -- >> Joris Meys >> Statistical consultant >> >> Ghent University >> Faculty of Bioscience Engineering >> Department of Mathematical Modelling, Statistics and Bio-Informatics >> >> tel : +32 (0)9 264 61 79 >> joris.m...@ugent.be >> --- >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php >> >>[[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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] `[` not recognized as a primitive in certain cases.
There is a difference between the symbol and the function (primitive or closure) to which it is bound. This: mc2 <- as.call(list(`[`,iris,2,"Species")) Evaluates `[` to its value, in this case the primitive object, and the primitive itself is incorporated into the returned call. If you were to do this: mc2 <- as.call(list(quote(`[`),iris,2,"Species")) The `[` would _not_ be evaluated, quote() would return the symbol, and the symbol would end up in the call. The two forms have virtually identical behavior as long as the call ends up getting evaluated in the same environment. On Tue, Mar 28, 2017 at 3:03 AM, Joris Meyswrote: > Dear, > > I have noticed this problem while looking at the following question on > Stackoverflow : > > http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments > > While going through callNextMethod, I've noticed the following odd > behaviour: > > mc <- call("[",iris,2,"Species") > > mc[[1]] > ## `[` > > is.primitive(`[`) > ## [1] TRUE > > is.primitive(mc[[1]]) > ## [1] FALSE > # Expected to be TRUE > > mc2 <- as.call(list(`[`,iris,2,"Species")) > > is.primitive(mc2[[1]]) > ## [1] TRUE > > So depending on how I construct the call (using call() or as.call() ), the > function `[` is or is not recognized as a primitive by is.primitive() > > The behaviour is counterintuitive and -unless I miss something obvious > here- likely to be a bug imho. I immediately admit that my C chops aren't > sufficient to come up with a patch. > > Cheers > Joris > > -- > Joris Meys > Statistical consultant > > Ghent University > Faculty of Bioscience Engineering > Department of Mathematical Modelling, Statistics and Bio-Informatics > > tel : +32 (0)9 264 61 79 > joris.m...@ugent.be > --- > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > > [[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
[Rd] `[` not recognized as a primitive in certain cases.
Dear, I have noticed this problem while looking at the following question on Stackoverflow : http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments While going through callNextMethod, I've noticed the following odd behaviour: mc <- call("[",iris,2,"Species") mc[[1]] ## `[` is.primitive(`[`) ## [1] TRUE is.primitive(mc[[1]]) ## [1] FALSE # Expected to be TRUE mc2 <- as.call(list(`[`,iris,2,"Species")) is.primitive(mc2[[1]]) ## [1] TRUE So depending on how I construct the call (using call() or as.call() ), the function `[` is or is not recognized as a primitive by is.primitive() The behaviour is counterintuitive and -unless I miss something obvious here- likely to be a bug imho. I immediately admit that my C chops aren't sufficient to come up with a patch. Cheers Joris -- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Mathematical Modelling, Statistics and Bio-Informatics tel : +32 (0)9 264 61 79 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel