Traits, rôles and other repurposed terms

Matt S Trout dbix-class at
Sat Feb 9 14:56:31 GMT 2008

On Fri, Feb 08, 2008 at 09:10:38AM -0500, Jeff Anderson wrote:
> On Feb 8, 2008 7:39 AM, Ovid <publiustemp-londonpm at> wrote:
> > I'm not claiming that this is an easy thing to really understand, but
> > it's the cleanest way I've encountered of solving hard compositional
> > problems.
> >
> I don't think it is hard to understand at all. It's just that i've
> learned that no matter how clean the solution is, if i don't keep it
> fresh in my mind then after about 3 or so months, it might as well be
> someone else's code.
> Look, the thing i really love about Perl is that i don't have to be
> stuck in a rigid OO world. If i want to attach an anonymous function
> ref to a hash, it's done.

my $hash = {};
$hash->{foo} = sub { ... };


my $meta = Moose::Meta::Class->create_anon_class;
$meta->add_method(foo => sub { ... });

my $class = $meta->class;


The way I originally "got" OO was by building hashes of subroutine
references and passing them around in code, then reading the various OO
perldocs and realising that I'd pretty much reinvented OO, badly.

Of course, the line between "this is a data structure, some of whose
contents happen to be functions", and "this is a poor reinvention of an
object system" is fuzzy and program-dependent. Class::Classless blurs
the syntactic line rather neatly to boot.

Possibly the biggest advantage of using OO over an ad-hoc data structure is
that in 3 months time it's still a set of perl classes and you still
remember how those work. Remembering whether $data->{foo} or $data->{bar}
happens to contain a function ... not so much. Of course, take -that-
argument to its logical conclusion and you find the silly arguments java
advocates make about why it's a good thing their language of choice is so

But basically, the majority of the people discussing in this thread are
talking about situations where they -have- decided to use OO and therefore
the conversation is framed in those terms.

I don't think any of us have a problem with the fact that often you decide
otherwise - but keeping reminding us of it isn't really adding anything to
the discussion. We get it - but it's not relevant.

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director          
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?  

More information about the mailing list