New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The cmp operator for user-defined classes lacks consistency #5202
Comments
From @titsukiIt seems that the cmp operator for user-defined classes lacks consistency. $ perl6 -e 'class MyClass {}; my $foo = MyClass.new(); my $bar = MyClass.new(); ($foo cmp $bar).perl.say' Comparing two instances of the type object Str seems to check its type, but comparing that of MyClass seems to check its address or something. I think that it should return Order::Same or something Exception. |
From @titsukiSorry, it is the post for perl6. On 2016-3月-27 日 07:05:53, cookbook_000@yahoo.co.jp wrote:
|
From [Unknown Contact. See original ticket]Sorry, it is the post for perl6. On 2016-3月-27 日 07:05:53, cookbook_000@yahoo.co.jp wrote:
|
From @tonycozOn Sun Mar 27 07:11:14 2016, cookbook_000@yahoo.co.jp wrote:
Looks like I do, I've moved it. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @lizmat
The default cmp calls .Stringy on the objects, so effectively the comparison becomes something like "MyClass<123345>" cmp "MyClass<234556>”. I guess we *could* introspect the object for public attributes and start cmp-ing them (if they are of the same type, of course). But I fear for the level of DWIM: it looks like becoming a WAT very fast. Perhaps we should only check for address equality, and if not, return Nil (indicating we don’t know). |
From @titsukiThank you for letting me know the mechanism of the cmp operator. On 2016-3月-28 月 08:03:09, elizabeth wrote:
|
Migrated from rt.perl.org#127793 (status was 'open')
Searchable as RT127793$
The text was updated successfully, but these errors were encountered: