Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Extra-lazy object oriented programming

by tobyink (Canon)
on Sep 08, 2014 at 21:49 UTC ( [id://1099913]=note: print w/replies, xml ) Need Help??


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 }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1099913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found