[Rd] "Ambiguous" variation of default environment in `getClasses()` (standard function vs. formal S4 method)

From: Janko Thyson <janko.thyson.rstuff_at_googlemail.com>
Date: Wed, 29 Aug 2012 11:25:58 +0200


Dear list,

This probably makes perfect sense from the language designers' perspective, but at least for me this was/is quite an interesting and unexpected behavior which I thought might be worth sharing:

The default value of argument |where|in function |getClasses()|seems to vary depending on whether |getClasses()|is called inside a *standard R function*or a *formal S4 method*. It is controlled by |.externalCallerEnv()|, which seems to be "vulnerable" to /lazy evaluation/and/or an "altered" /lexical scoping/structure (possible introduced by the definition of a formals S4 method?) and thus causes the variation**.

I found it quite hard to understand what's exactly going on as you need to manually debug `getClasses()` in order to find out what the default value of `where` (controlled by `|.externalCallerEnv()`) actually is in the various settings|. But that of course might as well be just me ;-)

For those interested, I tried to illustrate the behavior in this SO post: http://stackoverflow.com/questions/12166645/ambiguous-variation-of-default-environment-in-getclasses-standard-function/12174390#12174390

Best regards,
Janko Thyson

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 29 Aug 2012 - 09:33:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 29 Aug 2012 - 12:40:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive