> In Vadim's recent post about his AttrX::Moo module he describes his P6 > solution for bringing functionality he was used to having in P5 via Moo. > > (In another post I've asked about the option and relevance of using > Moo:from<Perl5> in P6. If you reply to this post please consider also > replying to that one. Thanks.) > > In discussing it he motivated his use of a Proxy as part of his `is Mooish` > trait for attributes. Aiui his reason for using it was that it seemed like a > simple and natural way to eliminate or reduce unwanted side-effects of using > a trait in the first place. But in so doing he's having to take on manually > driving type checking and has encountered semantic complexity that seems to > me to be a consequence of using Proxys. In addition, several of us have > suggested some generic weaknesses of Proxys, most notably performance. I've > started another thread for discussing Proxy's general strengths and > weaknesses. >
To be more precise, it's not just a consequence of using Proxy. It's a problem of typechecking of a value which is stored in a scalar container when Perl6 standard ways of doing it are not applicable; for example, checking against a user-supplied type. > This thread is for discussing alternatives for implementing what Vadim has > implemented, in particular an attribute trait that does what a Moo trigger > does. What are the pros and cons of available P6 techniques that allow > someone to create an attribute trait for a Moo like trigger? > To my understanding, I don't see another way to implement a trigger the way Moo/Moose does it unless $obj.attribute($value) notation is used (as I already stated it before). Trigger is a great example because what is important about it is that it is executed after its attribute is set. Current implementation of lvalue subs doesn't allow this kind of trick. Best regards, Vadim Belman