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

Luke Tierney luke at stat.uiowa.edu
Fri Oct 24 12:53:06 CEST 2008


Returning the internal R_MissingArg token was a bug.  From the svn
logs it looks like I fixed this bug back in June (so has been in
R-devel for a while) along with fixing a bug in the way system.time
used to be defined.  I no longer recall the details but suspect the
need to fix this arose in testing the fix to system.time.  The other
accessors should not retrun R_MissingArg either and will be fixed in
due course.

If your code is relying on this behavior then it would be a good idea
to have a look at your code and figure out why, as there is very
little useful that can be done with this missing arg token.  If after
that it turns out that there is a need to be able to test for whether
a binding represents a missing value then we can look into adding a
function that tests for this.  There is already sone desire to have a
way of checking whether a binding contains a delayed evaluation, so
maybe something like a function bindingStatus that returns one of
"active", "missing", "delayed" or "evaluated" makes sense.

You can use try or tryCatch to catch the error, but there is no clean
way currently to catch just this error.  Eventually we should have our
internaly signaled errors signal errors with a specific class so that
one could write something like

     tryCatch(get('x'), missingArgumentError = function(e) ...)

That is a ways off though.

Best,

luke

On Fri, 24 Oct 2008, Mark.Bravington at csiro.au wrote:

> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-devel mailing list