[Pdx-pm] Poll: traits

chromatic chromatic at wgz.org
Sat Nov 19 13:29:11 PST 2005

On Sat, 2005-11-19 at 13:22 -0800, Ovid wrote:

> Question:  are you saying that if I have this:
>   package Foo;
>   sub new { bless {} => shift }
>   sub name { return "Some name" }
> That this should automatically be considered a trait, too?

I certainly think so.

> Currently to make this is a trait you have to add "use Class::Trait
> 'base'" to the package.

> There are a number of reasons for this, but the most important is the
> internal introspection mechanism involved.

Agreed.  It's not such a problem in Perl 6, but Perl 5 doesn't have the
mechanisms that Perl 6 does.

I don't know how far you want to go with this, but perhaps there could
be a way to extract a trait from a package where you can provide a list
of the class's traity methods.

-- c

More information about the Pdx-pm-list mailing list