(apologies about the slow follow up) 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(); now perhaps "identical operations" needs a more refined definition but i think it should be a given that the above does not qualify. 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. >I would guess your definition is either circular, or would > restrict one to an unrealistically small subset of Perl. In the real > world, code like the above is perfectly normal. Well sure. Theres an infinite set of code that is perfectly normal but totally irrelevent to the question at hand. And i dont think we end up with a ciruclar definition. We end up with a recursive definition, but thats fine. > Again, your form of equality is perfectly good, but it's not privileged > over any other. As I said, i think it privileged in the sense that the ideal implementation would be totally consistant. The other form of equivelence that have been discussed are inconsistant with some set of other tests of equivelence. Also note im saying equivelence and not equality. The strong form of equality implies identity, but since we are posing tests that should be true across process boundaries we cant consider identity. > 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. > > > You would have to go further and say that the two structures are the > > > "only things" on those two computers, or that they are entangled with > > > other data (including the symbol table!) in the "same" ways. > > > > Id like to see an explanation for this assertion. > > As per the above example, things outside of the structures may hold > references into them. So if the two structures are to act the same, > they must have the same things holding references to them. And so on. 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. If references are deleted for instance, in one the actual sv will be free'ed, in the other it may not. But from the point of view of the object the sv involved is forever out of reach and thus the effect is the same. Now there may be external data structures that can be used to recover the sv, but i dont think thats relevent as the test cant know about them. 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. > > > 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. > > > > All I'm saying is, drop the pretense that this other comparison is > > > better according to some higher theoretical principle. > > > > Well i wont drop the pretense. I say its better because it contains > > less room for inconsistancy. > > I can agree with the second without agreeing to the first. Thats fair. :-) > > my $foo='foo'; > > deep_eq('foo',$foo); > > > > failed. At first i was surprised, then i remembered that one of the > > properties being checked is if elements are similarly readonly(). > > > > I say that there are situations where such a test is very valuable. > > I agree. :-) Cheers, yves -- perl -Mre=debug -e "/just|another|perl|hacker/"