You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my $n = { my class Num {} }().new; my $m = $n.WHICH.Str.split("|")[1].Num; for $n, $m { say (.WHICH, .^methods.elems) }
(Num|47923715919504 0)
(Num|47923715919504 63)
I have here two distinct objects, of different classes, with the same
.WHICH string. One is an instance of an empty class I've just defined,
and the other is a floating-point value in a built-in class. In the
above you can see that they really are of these two different classes
from the different lengths of their method lists.
This is related to [perl #128931], about .WHICH not distinguishing
identically-named classes, but there's a bit more to this. .WHICH applied
to the two Num classes in the above duly shows "Num" for both, so fails to
distinguish the class objects. But if given instances of two user-defined
classes, I think the object IDs that go into the default .WHICH would
be unique across all the classes, so the .WHICHes wouldn't clash.
The above clash depends on the non-default .WHICH arrangement for the
built-in Num class. Many other classes could produce similar clashes;
generally, custom .WHICH methods are relying on the class part of a
.WHICH string uniquely identifying the class.
Migrated from rt.perl.org#128934 (status was 'new')
Searchable as RT128934$
The text was updated successfully, but these errors were encountered: