Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

subtype with stringify

2 views
Skip to first unread message

John Macdonald

unread,
Feb 25, 2015, 5:00:03 PM2/25/15
to mo...@perl.org
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.Ma...@oicr.on.ca

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


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.

0 new messages