Skip Menu |
Report information
Id: 118339
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Conspicuous lack of warning when uselessly providing a precedence on a multi operator in Rakudo
Date: Wed, 5 Jun 2013 21:57:27 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 2.1k
<flussence> rn: multi infix:<%>($lhs, Str $rhs) is looser(&infix:<xx>) { $lhs.join: $rhs }; say '........' xx 8 % "\n" <camelia> rakudo b2072f, niecza v24-66-gaee6525: OUTPUT«........ ........ ........ ........ ........ ........ ........ ........␤» <flussence> those \s'es should be \n's... <colomon> that doesn't seem to have worked? <flussence> rn: multi infix:<%>($lhs, Str $rhs) is looser(&infix:<xx>) { $lhs.join: $rhs }; say ('........' xx 8) % "\n" <camelia> rakudo b2072f, niecza v24-66-gaee6525: OUTPUT«........␤........␤........␤........␤........␤........␤........␤........␤» <timotimo> yeah, because of $ instead of @ <colomon> oh, nevermind <timotimo> for the $lhs ;) <masak> timotimo: should still work, no? <masak> so, why doesn't it work for @lhs ? <moritz> ah, I know what's going on <quietfanatic> r: multi infix:<%>(\lhs, Str $rhs) { say "custom op"; lhs.join: $rhs }; say ( infix:<%>('........' xx 8, "\n") ).perl <camelia> rakudo b2072f: OUTPUT«custom op␤"........\n........\n........\n........\n........\n........\n........\n........"␤» <timotimo> oh, facepalm. <moritz> since there's already an infix %, you can't define a new one with a different precedence <flussence> oh! <moritz> so the precedence spec is simply ignored <quietfanatic> oh, I think it'd be nice if you could do that <timotimo> traits can be applied to the proto only? <quietfanatic> or wait, is it because it's installing it as a multi? <timotimo> can only be applied to the proto* <quietfanatic> I see <benabik> Multis with different precedence is probably a bad idea. <quietfanatic> r: sub infix:<%%%>(\lhs, Str $rhs) is looser(&infix:<xx>) { say lhs.perl; lhs.join: $rhs }; say ('........' xx 8 %%% "\n" ) <camelia> rakudo b2072f: OUTPUT«("........", "........", "........", "........", "........", "........", "........", "........").list␤........␤........␤........␤........␤........␤........␤........␤........␤» <quietfanatic> you're right <masak> could there maybe be a warning if you try to override the precedence? <masak> it feels wrongish that it just throws it away. <colomon> masak: I think an error, even * masak submits rakudobug <masak> colomon: better? :) <colomon> masak++


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org