Re: MX::Traits why can't traits be added with just new?

[email protected] (Tomas Doran)
Newsgroups perl.moose
Message-ID <[email protected]>
On 14 Mar 2012, at 02:14, Caleb Cushing wrote:

> Why are the options for using MX::Traits either
> 
> Class->with_traits(...) or Class->new_with_traits({ traits => ... });
> 
> why can't we have just a Class->new({ _traits => ... })?

Because then ->new returns an entirely different class to the one you asked for.

Which breaks people's expectations of what ->new does.

Also - this is hard to make work 'right', as what happens with classes which implement their own BUILDARGS / BUILD to do custom argument processing? How would we hook into that to get { _traits } out before construction, etc..

Cheers
t0m
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.