[Rd] changed behaviour of 'get' in 2.8.0: request for unchange

Mark.Bravington at csiro.au Mark.Bravington at csiro.au
Fri Oct 24 05:07:31 CEST 2008


There is an unannounced and non-backwards-compatible change to the behaviour of 'get' in R2.8.0. 'get'ting a missing value now causes an error, whereas hitherto it's just returned a "missing" object. For example, in R2.8.0 this happens:

test> getto <- function( x) get( 'x', sys.frame(1))
test> getto()
Error in get("x", sys.frame(1)) :
  argument "x" is missing, with no default

whereas in R2.7.1 this happens:

test> getto()

test>

i.e. a "missing" object.

While I can see some reason to the change, the error always would have gotten triggered eventually if it actually mattered-- and the new behaviour is inconsistent with other extraction functions:

test> getto2 <- function(x) sys.frame(1)$x
test> getto2()

test>

and the same goes for '[['.

'mget' also returns a missing object, rather than tripping an error.

The new 'get' breaks code in packages 'mvbutils' and 'debug'. At least 54 separate functions in those packages use 'get', so there'd be a fair bit of work in checking & changing all these to 'mget'! (Not to mention the entire rest of my code body...)

Is it possible to 'get' the old behaviour back?

Mark Bravington
CSIRO Mathematics & Information Science
CSIRO Marine Lab
Hobart
Australia



More information about the R-devel mailing list