Hello,  
  
I've seen a lot of bugs with before on attributes. The last one in 
HTML::FormBuilder :) What is the good practice to do that? Stop using before on 
attributes? Use direct value access? Personally, i think that lazy + default is 
good, but i see much people (including me) using before everywhere, because it 
is handy.  
  
#!/usr/bin/perl -w  
use MooseX::Declare;  
  
class Test {  
    has 'a' => (isa => 'Int', is => 'rw');  
  
    before a {  
        $self->do_calculations;  
    }  
    method do_calculations {  
        #after a lot of refactorings in some cases we check the $self->a  
        $self->a;  
    }  
}  
  
my $t = Test->new(a=>2);  
print $t->a;  
  
  
  

Reply via email to