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

From: Luke Tierney <luke_at_stat.uiowa.edu>
Date: Fri, 24 Oct 2008 05:53:06 -0500 (CDT)

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 24 Oct 2008 - 10:57:22 GMT

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 Fri 24 Oct 2008 - 17:30:26 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