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
.wrap doesn't work for routines declared in roles #4974
Comments
From @LLFournrole Foo { |
From @LLFournshould have mentioned, this is the error msg: ===SORRY!=== Error while compiling On Sat, Jan 2, 2016 at 3:49 AM perl6 via RT <perl6-bugs-followup@perl.org>
|
From @LLFournI golfed this down to: p6 -e 'role {sub foo {}; BEGIN &foo.clone() }' ===SORRY!=== Error while compiling -e For reasons I don't quite understand it's not using the right clone. If you p6 -e 'role {sub foo {}; BEGIN &foo.Mu::clone() }' On Sat, Jan 2, 2016 at 3:58 AM Lloyd Fournier <lloyd.fourn@gmail.com> wrote:
|
From @lizmat
One should realize that a role is nothing but a place-holder for code to be inserted when it is either does’d by a class, or punned into a class. It doesn't execute code in the mainline of the role after it has been parsed. Unless you use BEGIN of course. If you remove the BEGIN from you example, I *think* it does what you expect it to: role Foo { say "mainline"; method a { foo } BEGIN say "role done"; say Foo.arole done Note that the “mainline” is executed *after* the BEGIN block after the role. Disallowing BEGIN blocks inside a role, might be an option. OTOH, there might be valid uses for that as well, doing MOPpy things. So, all in all, I think this is a case of an LTA error. Is that what you intended to report? Liz |
The RT System itself - Status changed from 'new' to 'open' |
From @LLFournHey Liz, Sorry this was a case of me golfing something down then not explaining the multi trait_mod:<is>(Routine:D $meth,:$baz!) { role Foo { Obviously traits are run at compile time. To me if you can't use a trait Also I don't think there is any architectural reason why methods in roles Lloyds-iMac:~ llfourn$ perl6 -e 'sub foo { }; BEGIN On Sat, Jan 2, 2016 at 9:14 PM Elizabeth Mattijsen via RT <
|
Migrated from rt.perl.org#127112 (status was 'open')
Searchable as RT127112$
The text was updated successfully, but these errors were encountered: