P is for Practical | |
PerlMonks |
Re: Perl 6 OOP: before and after methods "CLOS style"by raiph (Deacon) |
on Feb 19, 2017 at 22:31 UTC ( [id://1182321]=note: print w/replies, xml ) | Need Help?? |
Hi AM,
Thanks for looking into Perl and visiting the monastery. :)
something similar to CLOS before/around/after methods. The v6.c version of the Perl 6 language is supposed to have a similar feature called `wrap` such that, given this code:
The `foo` call in the last line displays:
The above is equivalent to a CLOS `:around`. Be aware that, compared with Perl 5, Perl 6 is an immature upstart, and that's an understatement. I've tested that my v6.c compatible Rakudo (all Rakudos released in 2016 or later support v6.c) does the above correctly and I can see that a lot of simple cases are tested in S06-advanced/wrap.t but I also see lots of bugs in the bug queue with 'wrap' in their title, at least some of which are about this particular feature. A search of modules.perl6.org for 'before' yielded Method::Modifiers. I see recent commits by the author. The project's modules are tiny examples of MOP programming. They're probably worth a look over even if you don't actually `use Method::Modifiers;`. I see others have answered your other questions. Have The Appropriate Amount Of Fun....
In Section
Seekers of Perl Wisdom
|
|