From maechler at stat.math.ethz.ch  Mon May 23 09:24:40 2016
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 23 May 2016 09:24:40 +0200
Subject: [Rd] identical on closures
In-Reply-To: <573F8041.3040504@oracle.com>
References: <573F683C.6070904@oracle.com> <573F784F.5040704@oracle.com>
	<CADwqtCPXRLFAOMABi3n-CFk4kGZ7nEX9YXNwMhYrkJjg0c9bLA@mail.gmail.com>
	<573F8041.3040504@oracle.com>
Message-ID: <22338.45112.319937.15060@stat.math.ethz.ch>

>>>>> 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



[Rd] identical on closures
Martin Maechler