From bbolker at gmail.com  Mon Oct 12 15:51:01 2015
From: bbolker at gmail.com (Ben Bolker)
Date: Mon, 12 Oct 2015 13:51:01 +0000
Subject: [Rd] identical(..., ignore.environment=TRUE)
References: <561AF92D.90801@gmail.com> <561B1C93.3060803@gmail.com>
	<561B1E11.7050103@gmail.com>
Message-ID: <loom.20151012T154046-990@post.gmane.org>

Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:

BB>
> >> It seems odd/inconvenient to me that the "ignore.environment" argument
> >> of identical() only applies to closures (which I read as 'functions' --
> >> someone can enlighten me about the technical differences between
> >> functions and closures if they like -- see below for consequences of my
> >> confusion).  This is certainly not a bug, it's clearly documented, but
> >> it seems like a design flaw.  It would certainly be convenient to be
> >> able to ignore differences in environments when comparing complex
> >> objects with lots of deeply nested formula and terms objects with
> >> environments ...
> >>
> >>    Can anyone suggest a reason for this design?
> >>

  [snip]

> >> Actually, maybe I don't understand how this is supposed to work since I
> >> thought this would be TRUE:
> >>
> >>> f1 <- function() {}
> >>> f2 <- function() {}
> >>> environment(f1) <- new.env()
> >>> environment(f2) <- new.env()
> >>> identical(f1,f2,ignore.environment=TRUE)   ## FALSE
> > 
> > Those two functions likely have different srcref attributes.  If you
> > created f2 using f2 <- f1, you'd get your expected result.
> > 

[snip]

 Thanks for the clarification about closures vs. functions.

[snip]

You're right that the srcref attributes are different; although their
bodies are the same, they have their own environments that differ.
For me, this makes the intended use of ignore.environment= even more
puzzling; given that environments are not ignored recursively (that's
not exactly what I mean -- I mean ignoring all environments of components
of an object), I have trouble understanding the use case for
ignore.environnment ...  maybe it was developed before srcrefs 
existed?  

In the R code base it's used in checkConflicts (to see if a function
is re-exported) and in getAnywhere ...



[Rd] identical(..., ignore.environment=TRUE)
Ben Bolker