----- Original Message ---- > From: Stevan Little <stevan.lit...@iinteractive.com>
> -- > Actually, I said no to the idea of: > > with 'Role::Serializable' => { includes => [] }; > > meaning "don't compose any methods, but i still want to do this role", > because I > think that it is not very clear and could very easily be confusing to people. > After all you would never say: > > with 'Role::Serializable' => { excludes => [] }; > > it just wouldn't make sense. I just really never liked APIs where the lack of > something was significantly meaningful. First, you can say 'excludes => []' and it works just fine. It's a no-op. The 'includes => []' isn't a no-op simply because roles default to providing behavior. That being said, I do agree with the 'lack of something' comment. Can you propose a better syntax? Right now, there's no convenient way to say 'I want to use this role's interface, not its implementation'. Maybe something like: with 'Some::Role::Serializable' => '-interface'; Or: with 'Some::Role::Serializable' => { coerce => 'interface' }; I don't like either of those, really :) > Now, all that said, I actually really kind of like: > > with 'Role::Serializable' => { includes => [ 'to_xml' ] }; > > because it is clear and obvious and pretty useful. In fact, if you had > proposed > this originally, and not tied it to the includes => [] being a shortcut to a > "interface" type role, I would probably have said "go for it". > > In fact, I would be happy to accept a fork (no more patches now that we are > on > git) which implemented includes => [ 'to_xml' ] (along with tests and docs of > course) as long as it didn't do the "interface" role shortcut thing. I'll add this and some other things to MooseX::Role::Strict. It's possible that everyone will think my idea is silly and you might want to pick and choose features from it (or just ignore all. I'm fine with that, too). Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog - http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6