in reply to Re^2: NonMoose and (clean) inheritance
in thread NonMoose and (clean) inheritance
Builders are just generally a better idea than defaults. (MooseX::Manual::BestPractices even tells you so.) They give you a nice clean way to override the behaviour in subclasses.
If you use Moo or MooseX::AttributeShortcuts then you can even do:
has foo => (is => 'ro', builder => sub { ... });
... and it will automatically get "translated" to:
has foo => (is => 'ro', builder => '_build_foo'); sub _build_foo { ... }
... so builders can be just as convenient as defaults are.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: NonMoose and (clean) inheritance
by eco (Acolyte) on Mar 21, 2014 at 06:42 UTC |