[Rd] identical on closures

Martin Maechler maechler at stat.math.ethz.ch
Mon May 23 09:24:40 CEST 2016


>>>>> Mick Jordan <mick.jordan at oracle.com>
>>>>>     on Fri, 20 May 2016 14:23:13 -0700 writes:

    > On 5/20/16 2:00 PM, Gabriel Becker wrote:
    >> Specifically, the srcfile attribute of the srcref
    >> attribute of the two instances of the functions contain
    >> different environments, AFAICT.  Environments are
    >> compared only by exact pointer, so this forces return
    >> FALSE.

well, we had the  'ignore.environment'  optional argument
introduced exactly for these situations.

    > Thanks, and I realized that attributes(f) <- NULL does not
    > help as the srcref attribute is on the body components.

    > Mick

So, you have solved the puzzle now.

I agree that the current situation is not satisfactory.

One could use  all.equal(.,.)  and probably should in some
cases, but that builds on deparse() which ignores the
environment forcibly and also is not fast .. one of the properties
identical() was designed to have.

Clearly, we had introduced both the 'ignore.environment' and the
'ignore.bytcode' arguments to make identical() comparisons of
closures flexible and versatile.
But the later advent of the (sophisticated version of the)
srcref attribute has made simple use of identical() for closures
cumbersome and unintuitive for the average useR.

I think we should consider a new  'ignore.srcref' argument and
even consider using 'TRUE" as its default.

Martin



More information about the R-devel mailing list