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

subtype with stringify

From:
John Macdonald
Date:
February 25, 2015 21:45
Subject:
subtype with stringify
Message ID:
01EF6156B387B14E8278ECC376793BE18F579CBB@exmb2.ad.oicr.on.ca
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


Tel:

Email: John.Macdonald@oicr.on.ca

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


www.oicr.on.ca<http://www.oicr.on.ca/>

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.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About