Closed perigrin closed 11 years ago
@perigrin I am not sure we want to add lazyiness predicates to the core attributes actually. I would prefer to add a generic has_trait
mechanism to all things (classes, attributes, methods). And then let lazy just do it's thing.
Yeah, I said I wasn't happy with that solution on IRC. My first idea was to apply a role to $meta that raised a Boolean flag of some kind but role applications to instances is still Moose levels of ugly and I didn't chase that down.
Adding a traits method would work, but mop::object will still end up having to explicitly check for the lazy trait unless we come up with a "do not initialize this attribute" flag that can be used generically by anything that wants the mop to skip initialization, or we make initialization more intelligent and overrideable. Both plans introduce performance and simplicity issues.
This was simply a way to start thinking about those things. — Sent from Mailbox for iPhone
On Mon, Jul 29, 2013 at 8:03 AM, Stevan Little notifications@github.com wrote:
@perigrin I am not sure we want to add lazyiness predicates to the core attributes actually. I would prefer to add a generic
has_trait
mechanism to all things (classes, attributes, methods). And then let lazy just do it's thing.Reply to this email directly or view it on GitHub: https://github.com/stevan/p5-mop-redux/pull/47#issuecomment-21715185
Actually, my plan was to just remove the default value from the attribute, and then make the lazy event handler do the installation. Without a default value, the constructor will just ignore it.
Hmm that could work, but the movers arrive in 20 minutes so it's outside of the time I have this morning.
I've added a generic trait mechanism to mop::attribute
though.
This was done in 1d61bea.
Change the syntax for lazy attributes from:
to
or
and add
class Foo is lazy { }
which makes all attributes lazy in a given class.