On Tue, Jul 05, 2005 at 10:15:16AM +0200, demerphq wrote: > (apologies about the slow follow up)
not slow in my book :-) > On 7/4/05, Andrew Pimlott <[EMAIL PROTECTED]> wrote: > > On Mon, Jul 04, 2005 at 12:36:29AM +0200, demerphq wrote: > > > On 7/3/05, Andrew Pimlott <[EMAIL PROTECTED]> wrote: > > > >Would using > > > > > > > > my $s = sub { $a->[0] = 1; $_[0]; } > > > > > > > > above also be "looking at refaddrs"? > > > > > > No. But it wouldnt be symmetric would it? > > > > It's no less symmetric that the first example. In fact, I would say > > it's symmetric. I'm calling the same code on each. What is your > > definition? > > Calling the same code on each is not necessarilly the same thing as > "performing identical operations on each". > > Your orginal example was stringifying the refs, which is much the same as > > $obj->{foo} = rand(); > $obj->{foo} = rand(); I agree that 1) getting values from "the world" (rand()) and 2) getting the address of refs ("$ref") can be disqualified for our purposes. > I think that identical operation in this sense could be defined as an > operation that when inspected alone passes all difference detection > tests posed it (with the usual caveats about how to deal with > references). While this does imply a recursive definition IMO it > doesnt pose philisophical problems as ultimately you end up comparing > leafs or IOW normal scalars and i think the definitions of equivelence > there are well understood. Right--this means you're defining your form of equality by an algorithm, not by some concise property it satisfies. Which is fine, but it's a distinction worth noting. > > Both your equality and is_deeply are belied by totally > > normal, plausible code. That's all I wanted to point out. > > Belied by normal code? Im not sure what you mean. Sorry, "proven not to be equivalent by normal code". Ie, there are cases (eg the example above) where we can tell them apart without doing anything "abnormal". > Actually i don't agree with this. By including refcount data you are > expanding the black box of the test out to the level of the full perl > run-time state. I dont think this is relevent. From the POV of the > overall strucutre itself there is no difference between a heavily > referenced structure and one that isnt referenced outside of itself. I don't mean looking at the refcount (or other implementation details) per se; I mean that if something outside references the structure (or part of it), then performing operations on that something (not explicitly mentioning the structure) might change the structure. So it matters who else is holding references to the structure. > Having said that I suppose there are situations where you want to dial > the point of view back to the level of the full perl implementation > but I think its not too useful for testing anything but perl itself. Don't worry, I'm not asking for that! > > > > Two structures are considered to be the same if you could not > > > > observe the difference without using a) finding the address of a > > > > reference, b) reference comparison, or c) variable assignment. > > > > > > Do you think this is the way is_deeply() behaves? Its not actually. > > > > I could believe I've missed something, but I'm curious what. > > Im not sure the right way to say this. An example perhaps. > > my ($x,$y)=([],[]); > $_->[0]=$_ for $x,$y; > $x->[0]=[$x->[0]]; > $y->[0]=[$y->[0]] for 1..2; > > $x and $y are different. They have similar contents. Each node alone > is indistinguishable from the other, yet they are different. > > I dont think that squares with your definition as it requires taking > the refaddr to do. Hmm... I see that is_deeply reports that $x and $y are different. You're saying that you can't see the difference under my conditions (a-c) above? Ok, you're right. I was not aware that is_deeply would catch that (I thought it would loop forever). So I was describing my imaginary version of is_deeply that doesn't have any fancy loop detection. Forget about it. Andrew