Mo supports chained accessors
with the help of ingydotnet++ valuable suggestions, Mo now has the option to chain accessors:
package ChainedAccessors;
use Mo qw/chain/;
has 'first' => (chain => 1);
has 'second' => (chain => 1);
package main;
$f = ChainedAccessors->new;
$f->first(1)->second(2);
$f->first; # 1
$f->second; # 2
thanks also for the feedback in response to my previous blog post
Looks handy, although having to specify chain when loading Mo and also for each attribute seems a bit odd - is that for technical reasons?
(also, looks like my comment on the previous post never made it through, wasn't particularly important though!)
Looks handy, although having to specify chain when loading Mo and also for each attribute seems a bit odd - is that for technical reasons?
(also, looks like my comment on the previous post never made it through, wasn't particularly important though!)
1.)
use Mo qw/feature1 feature2/;
allows you to only load the features that you need, for performance reasons
https://github.com/ingydotnet/mo-pm/blob/master/lib/Mo/Features.pod
2.)
has 'first' => (chain => 1);
chaining must requested per accessor, as it cannot be the default (see my older post and the related comments)
3.) it might be possible to add a feature called e.g. chain_by_default, so you would only have to say chain => 0 if chaining is not desired, not sure whether there is any interest for that in the Mo community
That seems like the kind of feature that justifies the eventual creation of M.pm
@Adam Kennedy
not sure what your point is...!?
https://metacpan.org/module/M