Bug in Moose, Moo or forks?

2015-02-25 Thread Octavian Rasnita
Hello, I have the following test code. Here Moose and Moo are not useful so can be commented, but in production code they are needed. use forks; use Moose; use Moo; $SIG{__DIE__} = sub { print "thread died: @_\n" if @_; exit; }; my $thread = threads->create( sub { print "Thread running

Re: incomplete role consumption?

2015-02-25 Thread Gianni Ceccarelli
Short version: you have a dependency loop, and your code, as written, can not work. Longer version: main.pl loads Test1, which loads TestRole, which loads TestGlue, which loads Test1. Boom! On 2015-02-25 Daniel Hermann wrote: > The above code works if > > - I do not 'use Test2' in TestGlue.pm o

Re: incomplete role consumption?

2015-02-25 Thread Ben Tilly
To understand this you need to understand how Perl handles circular dependencies. When we execute code that loads other code (for instance use at compile time, require at run time, or a variety of things in Moose), Perl will mark the current package as incompletely loaded then go off and try to lo

subtype with stringify

2015-02-25 Thread John Macdonald
Is it possible to define a subtype that will provide a stringify method? I see MooseX::Exception::Base::Stringify that can be provided as a trait for an attribute, but that gets onerous (and error-prone) when *every* time you declare an attribute that has "... isa => MyType ..." you want to also

incomplete role consumption?

2015-02-25 Thread Daniel Hermann
Hi, I have two classes Test1 and Test2, both consuming the role TestRole which uses another class TestGlue, which in turn uses Test1 and Test2 internally. My main program uses Test1 and Test2 and runs into a Moose error when it calls a method in Test2 provided by TestRole: Can't locate objec