Hacker News new | ask | show | jobs
by csirac2 4337 days ago
Sure. And just for attributes, there's also delegation, read-only attributes, builders, lazy init, roles, modifiers which are enforced at construction time (if `required` is true).

Moose isn't hard to implement, it's actually had quite a few alternate implementations even in Perl. Python has enthought's traits package, and I've just been pointed to https://github.com/frasertweedale/elk as well.

BTW it sucks to nit-pick, but the Moose version isn't any more verbose than yours:

    package Foo;
    use Moose;
    has 'bar' => ( isa => 'Integer' );