krautcat has asked for the wisdom of the Perl Monks concerning the following question:
Hello, dear Perl monkers! I am trying to understand Moo object system.
To clarify my experience, I have background in OO programming with C++03, Python and Ruby. Also I have vague representation of OOP in Perl (Moose or Mouse, I cannot remember exactly what type of OO system I had used). Now I want to use Moo as lightweight OO system for some of my CLI apps.
I've read some information about Moo, tried search answer on my question here and in the web, but I still don't understand difference of isa and coerce args of has sub in Moo. As far as I can understand, isa is just simple anonymous sub wich is executed when we don't provide sub for coerce arg. Also I've read that it can be omitted on non-debug builds. How does it can be achieved? And am I right when I'm saying that isa sub isn't executed when we provide coerce sub? So what is the point of using each method? And the most important: when does each method is executed? I.e. when we access the attribute (setting or getting its' value) or when we build it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moo's coerce and isa difference
by choroba (Cardinal) on Sep 11, 2017 at 09:40 UTC | |
|
Re: Moo's coerce and isa difference
by Haarg (Priest) on Sep 11, 2017 at 13:48 UTC | |
by krautcat (Acolyte) on Sep 14, 2017 at 18:46 UTC | |
by 1nickt (Canon) on Sep 15, 2017 at 17:52 UTC |