Fergal Daly wrote:
On 7/2/05, Michael Peters <[EMAIL PROTECTED]> wrote:

But if we say
  x=y and x=z can we then say that x,x != y,z

If say
  $x = [];
  $y = [];
  $z = [];
  is_deeply($x, $y); # passes
  is_deeply($x, $z): # passes
  is_deeply([$x,$x], [$y, $z]); # fails for some reason

If we broke this out into a formal logical proof, the only way
that x,x != y,z would would is if x != y or x != z, or both.


The reason this happens is because the calls to is_deeply are entirely
independent. If is_deeply behaved as Yves wanted _and_ the results of
multiple calls were consistent then actually the second call would
fail because we've already matched $x with $y so we can't match it up
with $z too.

That's what I'm trying to point out. If we follow the reasoning fully out then the second call to is_deeply() would need to fail as well as the first. Try explaining that to the someone using it.

calls to is_deeply() *need* to behave independently. It should only fail if the things being compared are structurally equivalent. To have it 'maintain state' between calls (even if that state is maintained through inside of other structures) would just be asking for weird things to happen.

If we try to have is_deeply() modify the arguments it recieves to see if they behave the same then we run into all kinds of issues with tied structures or objects that are mere interfaces with other, more permanent storage.

--
Michael Peters
Developer
Plus Three, LP

Reply via email to