Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

.max methods on hashes and pairs seem to ignore their :by argument in Rakudo #2975

Open p6rt opened 11 years ago

p6rt commented 11 years ago

Migrated from rt.perl.org#115758 (status was 'open')

Searchable as RT115758$

p6rt commented 11 years ago

From @masak

\ r​: say { 0 => 1, 1 => 0 }.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ looks like a bug to me. * masak submits rakudobug \ grondilu++ # discoverer \ r​: say { 0 => 1, 1 => 0 }.pairs.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ r​: say (0 => 1, 1 => 0).max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«1 => 0␤» \ r​: say max :by(*.value), { 0 => 1, 1 => 0 }.list \ rakudo a41a48​: OUTPUT«"0" => 1␤» \ I think a number of method forms may simply be missing their :by parameter. \ r​: say List.can('max') \ rakudo a41a48​: OUTPUT«max␤» \ r​: say List.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ r​: say Parcel.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ seems it should work \ weird.

p6rt commented 7 years ago

From @MasterDuke17

On Fri Nov 16 03​:25​:43 2012, masak wrote​:

\ r​: say { 0 => 1, 1 => 0 }.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ looks like a bug to me. * masak submits rakudobug \ grondilu++ # discoverer \ r​: say { 0 => 1, 1 => 0 }.pairs.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ r​: say (0 => 1, 1 => 0).max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«1 => 0␤» \ r​: say max :by(*.value), { 0 => 1, 1 => 0 }.list \ rakudo a41a48​: OUTPUT«"0" => 1␤» \ I think a number of method forms may simply be missing their :by parameter. \ r​: say List.can('max') \ rakudo a41a48​: OUTPUT«max␤» \ r​: say List.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ r​: say Parcel.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ seems it should work \ weird.

Some notes from today​:

18​:18 MasterDuke r​: say (0 => 1, 1 => 0).max(​:by(*.value)) 18​:18 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«1 => 0␤» 18​:18 MasterDuke r​: say (0 => 1, 1 => 0).max(*.value) 18​:18 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«0 => 1␤» 18​:20 MasterDuke r​: say List.can("max")[0].signature.perl 18​:20 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«​:($​: | is raw)␤» 18​:20 MasterDuke i was looking at RT #​115758, but it's pretty old 18​:20 synopsebot6 Link​: https://rt-archive.perl.org/perl6//Publ​ic/Bug/Display.html?id=115758 18​:21 MasterDuke r​: say max :by(*.value), { 0 => 1, 1 => 0 } 18​:21 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«0 => 1␤»

19​:55 MasterDuke masak, moritz​: do you think RT #​115758 is still valid?

20​:14 masak MasterDuke​: yes, I think it's still valid. unless something has happened that's outside of the scope of what I'm reading in that ticket. but I know of no such thing.

p6rt commented 7 years ago

From @MasterDuke17

On Tue Aug 30 20​:00​:31 2016, ddgreen@​gmail.com wrote​:

On Fri Nov 16 03​:25​:43 2012, masak wrote​:

\ r​: say { 0 => 1, 1 => 0 }.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ looks like a bug to me. * masak submits rakudobug \ grondilu++ # discoverer \ r​: say { 0 => 1, 1 => 0 }.pairs.max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«"1" => 0␤» \ r​: say (0 => 1, 1 => 0).max(​:by(*.value)) \ rakudo a41a48​: OUTPUT«1 => 0␤» \ r​: say max :by(*.value), { 0 => 1, 1 => 0 }.list \ rakudo a41a48​: OUTPUT«"0" => 1␤» \ I think a number of method forms may simply be missing their :by parameter. \ r​: say List.can('max') \ rakudo a41a48​: OUTPUT«max␤» \ r​: say List.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ r​: say Parcel.can('max')[0].signature.perl \ rakudo a41a48​: OUTPUT«​:(​: $by = { ... }, Mu *%_)␤» \ seems it should work \ weird.

Some notes from today​:

18​:18 MasterDuke r​: say (0 => 1, 1 => 0).max(​:by(*.value)) 18​:18 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«1 => 0␤» 18​:18 MasterDuke r​: say (0 => 1, 1 => 0).max(*.value) 18​:18 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«0 => 1␤» 18​:20 MasterDuke r​: say List.can("max")[0].signature.perl 18​:20 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«​:($​: | is raw)␤» 18​:20 MasterDuke i was looking at RT #​115758, but it's pretty old 18​:20 synopsebot6 Link​: https://rt-archive.perl.org/perl6//Publ ic/Bug/Display.html?id=115758 18​:21 MasterDuke r​: say max :by(*.value), { 0 => 1, 1 => 0 } 18​:21 camelia rakudo-moar 68443f, rakudo-jvm cd19db​: OUTPUT«0 => 1␤»

19​:55 MasterDuke masak, moritz​: do you think RT #​115758 is still valid?

20​:14 masak MasterDuke​: yes, I think it's still valid. unless something has happened that's outside of the scope of what I'm reading in that ticket. but I know of no such thing.

Commentary from jnthn​: http://irclog.perlgeek.de/perl6-dev/2016-08-31#i_13127809

Some of the most relevant portions quoted below.

\ I'm curious if any other non-max methods take :by though. I'd thought we were doing that on the sub forms to not confuse the transform with a list value \ But on the method forms there's no such ambiguity \ git grep 'method.*​:by' (or git grep 'method.*​:&by') \ returns no results \ Suggests "no" then :) \ In which case the ticket is kinda asking us to add them *everywhere* since it'd be odd to do it just for max. :) \ But I'm not really that inclined to. \ Yeah, so far as I recall we went that way on the subs, and positional for the methods, and it was a deliberate choice

Based on the above conversation I'm going to recommend this be closed as not a bug.

p6rt commented 7 years ago

The RT System itself - Status changed from 'new' to 'open'