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
List.invert only works if the list contains Pairs but the error message isn't very clear about that fact #5540
Comments
From @dogbert17dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -v dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -e 'say (1,2,3).invert' http://irclog.perlgeek.de/perl6/2016-08-06 12:58:01 dogbert17 | m: say (1,2,3).invert # ?? ... 13:16:34 lizmat | apparently you can only List.invert if the List contains pairs |
From @zoffixznetMy vote is to not have .invert on listy things at all. The fact that it can't work in some cases, depending on what things a list contains, is a good indication to me that it's not a list method. The second option for me would be to improve the error message and make it work only on lists with just Pairs in them, so |
The RT System itself - Status changed from 'new' to 'open' |
From @TimToadyBinding of the map routine internally now requires list elements to bind as Pair, which improves the error message. (The alternate approach of inserting a CATCH into the map closure could in theory produce an even better message, but it appeared to slow things down more than the Pair binding approach.) Note that we cannot make the degenerate case of .invert the same as .antipairs, because .invert must expand list values into multiple antipairs. In any case, .antipairs is 5-10 times faster since it doesn't have to check for such expansion. Fix in baeabb4c4e8f5d223da8632130b4dfcd020d40ba Test in 63c1f009b910a5c87186b2201383682ad7a0f724 |
1 similar comment
From @TimToadyBinding of the map routine internally now requires list elements to bind as Pair, which improves the error message. (The alternate approach of inserting a CATCH into the map closure could in theory produce an even better message, but it appeared to slow things down more than the Pair binding approach.) Note that we cannot make the degenerate case of .invert the same as .antipairs, because .invert must expand list values into multiple antipairs. In any case, .antipairs is 5-10 times faster since it doesn't have to check for such expansion. Fix in baeabb4c4e8f5d223da8632130b4dfcd020d40ba Test in 63c1f009b910a5c87186b2201383682ad7a0f724 |
@TimToady - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#128860 (status was 'resolved')
Searchable as RT128860$
The text was updated successfully, but these errors were encountered: