develooper Front page | perl.moose | Postings from February 2015

subtype with stringify

John Macdonald
February 25, 2015 21:45
subtype with stringify
Message ID:
Is it possible to define a subtype that will provide a stringify method?

I see MooseX::Exception::Base::Stringify that can be provided as a trait for an attribute, but that gets onerous (and error-prone) when *every* time you declare an attribute that has "... isa => MyType ..." you want to also have "... traits => [qw{MooseX::Exception::Stringify}] ..." applied. It would be much more convenient to have the subtype provide the stringify capability.  I'm visualizing something like either a parameter to the subtype declaration to specify stringify (or other overloads, perhaps); or alternately a separate mechanism (like the way coerce is done) outside the subtype declaration that modifies it to have the overloaded stringify.

John Macdonald
Software Engineer

Ontario Institute for Cancer Research
MaRS Centre

661 University Avenue

Suite 510
Toronto, Ontario

Canada M5G 0A3



Toll-free: 1-866-678-6427
Twitter: @OICR_news<>

This message and any attachments may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this message in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this message may not be that of the organization. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About