On Thu, Sep 30, 2010 at 05:13:28PM -0500, Evan Carroll wrote:
> I have two questions:
>
> * Should the Array trait using List::Util permit regexes? i.e.
>
> perl -MList::Util -wE'use List::Util qw/first/; say first {/foo/}
> qw/bar foo bazko bazfoo/'
>
> package Class;
> use Moose;
> has "foo" => ( isa => "ArrayRef", is => "rw", traits => ['Array'],
> handles => { first_foo => foo } )
>
> Class->new(foo=>[qw/foo bar baz quz/])->first_foo(qr/foo/);
No. Your example isn't using a regex directly either, it's effectively
"first(sub { /foo/ }, ...), which is the same thing we support.
> * Regarding the new 1.15 in git, why does the new
> Moose::Meta::Method::Accessor::Native::*, stuff use string eval? What
> was wrong with the old approach.
>
> Native Trait delegations are now all generated as inline code. This should
> be much faster than the previous method of delegation. In the best case,
> native trait methods will be very highly optimized.
>
> How is string eval generation better? I mean is the end goal just to
> shave a function-call at the expense of turning Moose into
> perl-pre-processor written in perl? Wouldn't this code be better in
> List::Util? Why should Moose have the sanitation features here? I'd be
> more interested in reading more about this optimization. I've never
> seen any code on CPAN do it.
Moose *already* does this pretty extensively for things like
constructors, destructors, and accessors - this is just extending
Moose's existing features to cover more types of accessors.
-doy