On 7/1/2005 7:39 AM, demerphq wrote:
> On 6/30/05, Michael G Schwern <[EMAIL PROTECTED]> wrote:
>> Yves has some controversial ideas about what is and is not data structure
>> equivalence.  I'd like comments on it.
> 
> Well while im disappointed that its considered to be a controversial
> position (why is accuracy and correctness controversial?) i do beleive
> it is important that this is debated outside of just the perl-qa list
> (its not that high traffic or visibility IMO) so I have taken the
> liberty of starting a thread on Perlmonks about this. It is at
> http://perlmonks.org/index.pl?node_id=471639.

Despite my subscription to this list I consider myself an end user as far as
this stuff is concerned so I'll chip in my $0.02.

I can't recall ever (deliberately) creating a data structure where this would
matter. For me, references have always been an implementation detail of complex
data structures. Checking the refcounts seemed like it was getting into details
that I didn't really care about when doing functional testing, and didn't want
to have to care about. As such, my initial position was to keep the existing
behavior.

After reading this thread, I've changed my mind.

The example you cited is a case where the data structures themselves _are_
different, even though they look the same. I think that is_deeply() should
recognize that. The change might break a few of my tests, but the updates would
be trivial. This inconvenience is IMHO far outweighed by the potential benefit
of detecting a class of errors that might be hard to detect otherwise.

That said, I can envision cases where a programmer might have repeating
references as an artifact of creating the structure: maybe because he was too
lazy to make copies, maybe because he wanted to save memory. In these situations
he wouldn't care about the distinction so it would be good to have a function
that allows testing in that way. Because this is an intentional "I'm going to do
something clever but dangerous" decision, it's fair to place the burden of
additional testing here.

-mjc

Reply via email to