develooper Front page | perl.moose | Postings from March 2015

Moo, multiple-inheritance, unexpectedly uninitialized attributes

Thread Next
From:
Diab Jerius
Date:
March 26, 2015 22:24
Subject:
Moo, multiple-inheritance, unexpectedly uninitialized attributes
Message ID:
CADpyd5Az3Ek3nXZGXfU-3TX0fWoF7tVuQ1_wbXJ1iwzEhyCxsA@mail.gmail.com
I've translated some code using multiple inheritance to Moo, and am
seeing some unexpected  behavior, namely that attributes inherited
from the second parent class are not properly initialized.

I've attached simplified versions of the pre- and post- Moo code.  The
pre-Moo code generates this:

$ perl tst1
b1
b2

The Moo code outputs this:

$ perl tst2
b1
Use of uninitialized value in say at tst2 line 30.

In tst2, if I explicitly initialize the attribute from the second class:

  my $q = C11->new( b2 => 'BBB' );

It is still output as uninitialized.

Would someone please point out what I'm missing?

Thanks,

Diab

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About