in reply to Extra-lazy object oriented programming

You might like this:

package Foo { use Moo; has [qw/ foo bar baz /], is => "ro"; has [qw/ quuux xyzzy /], is => "rw"; }

Also take a look at Moose::Tiny which could easily be ported to Moo.

Replies are listed 'Best First'.
Re^2: Extra-lazy object oriented programming
by Anonymous Monk on Sep 09, 2014 at 00:39 UTC

    Thanks Toby. The lists of names is nice, but then they don't have defaults. Which would mean the constructors would have to hold the default values. I'd rather the defaults were in the definition.

    Moose::Tiny and Object::Tiny only do read-only, so they won't work.

    Something like this might work:

      If want defaults:

      use Moo; has [qw/ foo bar baz /], is => "lazy", builder => 1; sub _build_foo { [] } sub _build_bar { {} } sub _build_baz { 42 }