[Perl5-syntax] Re: Syntax for Method Traits
Cory Watson
jheephat at gmail.com
Wed May 20 12:07:20 GMT 2009
On Thu, May 7, 2009 at 7:25 AM, Cory Watson <jheephat at gmail.com> wrote:
> rafl asked me to come to p5-syntax to proffer my work on method traits
> and to wrangle up any suggestions for syntax. At present, I've got a
> fork of MooseX::Method::Signatures on github[0] that works with the
> following:
>
> method foo(Str :$foo) is Trait1 {
>
> This applies Trait1 to the meta-method. The project I'm working on,
> however, desires something slightly more complex:
>
> method foo(Str :$foo) is Trait1(attr => 'value') {
Looks as if rafl is looking to merge my patches in, so I'll update the
list on the final implementation that works in my patches:
method foo(Str :$foo) is (Trait1, Trait2) {
The above works today. I've got it in mind to extend it as stated in
the original email to allow for parameters:
method foo(Str :$foo) is (Trait1, Trait2(attr => 'value')) {
My particular use is decorating methods with meta-data for use in a
UI. So I'm gunning to have something like:
method does_something(Str :$name) is (Displayable(label => 'Does Something')) {
This is the same technique I use with Attributes as laid out in
Moose::Cookbook::Meta::Recipe3
--
Cory 'G' Watson
http://www.onemogin.com
More information about the Perl5-syntax
mailing list