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
For a multi trait_mod:<is>(Routine:D, |) is always called on the proto, never on the actual candidate. This has been deemed wrong in the discussion: https://irclogs.raku.org/raku-dev/2023-06-05.html
multi sub trait_mod:<is>(Routine \r, :$renamed) { r.candidates.say; r does role :: { method name { $renamed } } }
proto sub foo(|) is renamed<foo-proto> { * }
multi sub foo(Int $) { say &?ROUTINE.name }
multi sub foo(Str $) is renamed<stringer> { say &?ROUTINE.name }
multi sub foo(Failure) is renamed<failer> { fail('oi‽') }
foo(42);
foo('answer');
# foo(Failure);
Compiler version (perl6 -v or raku -v): Welcome to Rakudo™ v2023.05-98-ge8b477b58. Implementing the Raku® Programming Language v6.d. Built on MoarVM version 2023.05.
The text was updated successfully, but these errors were encountered:
It's called on the candidate, but roles are not closures (and ideally we'll find a way to make this spit out a warning in the new compiler frontend), so $renamed in the method always references the value in the most recent call of the trait.
Indeed, I stepped into the "not quite golfed enough"-trap.
multi sub trait_mod:<is>(Routine \r, :$thiscalled) { dd r; }
proto sub foo(|) is thiscalled<?> { }
multi sub foo(Str $s, :$isa = <stringer>) is thiscalled<?> { }
multi sub foo(Int $s, :$isa = <inter>) is thiscalled<?> { }
OUTPUT:
Sub foo = proto sub foo (|) { #`(Sub|5551856403328) ... }
Sub foo = multi sub foo (Str $s, :$isa = "stringer") { #`(Sub|5551856429696) ... }
Sub foo = multi sub foo (Int $s, :$isa = "inter") { #`(Sub|5551856430848) ... }
For a multi
trait_mod:<is>(Routine:D, |)
is always called on the proto, never on the actual candidate. This has been deemed wrong in the discussion: https://irclogs.raku.org/raku-dev/2023-06-05.htmlExpected Output
Actual Output
Environment
Linux dexhome 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
perl6 -v
orraku -v
):Welcome to Rakudo™ v2023.05-98-ge8b477b58. Implementing the Raku® Programming Language v6.d. Built on MoarVM version 2023.05.
The text was updated successfully, but these errors were encountered: