[Bioperl-l] Moose and Roles

Chris Fields cjfields at illinois.edu
Tue May 26 19:40:20 EDT 2009

On May 26, 2009, at 4:35 PM, Mark A. Jensen wrote:

> ----- Original Message ----- From: "Chris Mungall" <cjm at berkeleybop.org 
> >
> To: "Mark A. Jensen" <maj at fortinbras.us>
> Cc: "Chris Fields" <cjfields at illinois.edu>; "BioPerl List" <bioperl-l at lists.open-bio.org 
> >
> Sent: Tuesday, May 26, 2009 4:26 PM
> Subject: Re: [Bioperl-l] Moose and Roles
>> This seems to be overloading the namespacing mechanism. Presumably   
>> each $X in {Root,Seq,Phylo,...} etc will need their own roles.  
>> Would  these go in Bio::Role::$X:: or Bio::$X::Role::?
> Right-- Roles could (should?) be applied across objects in higher  
> level domains
> (e.g., I can imagine roles that both Hit::GenericHit and  
> HSP::GenericHSP could
> take on), so I would push the Bio::Role::[Path] direction.

I think Bio::Role::X as well; this seems to be the general pattern  
most devs using Moose are following.  Roles tend to flatten the  
inheritance tree anyway; see Ovid's articles on Roles at use.perl.org  
for examples of this.

Is this what you mean chris?  Or do you think confining to a fixed  
namespace is not flexible enough (and do you prefer one of the two  
forms below)?

>> For the names I prefer either (a) the convention of using  
>> adjectives  or adjectival phrases to denote roles or (b) spelling  
>> it out rather  than using hungarian notation (e.g. DescribableRole  
>> rather than  Describable)
> +1; would you accept predicates such as "DoesDescriptiveStats"?

That's an 'Ovidism'; not necessarily a bad thing, but it's a mouthful  
for a simple role.  Bio::Role::Describes, perhaps?

package Bio::Foo;
use Bio::Root::Moose; # sets Bio::Root::Root as base class
with 'Bio::Role::Describes';

This isn't too far from the perl 6 syntax for roles:

class Bio::Foo does Bio::Role::Describe {...}


More information about the Bioperl-l mailing list