in reply to Delegating to a role in Moose

Hello nysus,

It looks like you can't have with "Foo"; in your class and handles "Foo"; in an attribute at the same time, which is quite natural - you either impersonate a role, or point to someone else performing it for you. You have to choose.

I'm new to Moose, though. Take my advice with a grain of salt.

Hope that helps.

UPD: a minimal example

==> doo.pl <== #!/usr/bin/env perl use strict; use warnings; use Foo; print Foo->new->bar, "\n"; ==> Foo.pm <== package Foo; use Moose; with "Roo"; use Goo; has goo => is => "rw", isa => "Roo", handles => "Roo" , default => sub { Goo->new; }; 1; ==> Goo.pm <== package Goo; use Moose; with "Roo"; 1; ==> Roo.pm <== package Roo; use Moose::Role; sub bar { 42 }; 1;

This doesn't work. One needs to comment out either "with", or "handles" in Foo.pm for the perl -I. doo.pl to output 42 correctly.