subtype with stringify
[email protected] (John Macdonald) Wed, 25 Feb 2015 21:45:19 +0000
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
--_000_01EF6156B387B14E8278ECC376793BE18F579CBBexmb2adoicronca_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 fo=
r an attribute, but that gets onerous (and error-prone) when *every* time y=
ou declare an attribute that has "... isa =3D> MyType ..." you want to also=
have "... traits =3D> [qw{MooseX::Exception::Stringify}] ..." applied. It =
would be much more convenient to have the subtype provide the stringify cap=
ability. I'm visualizing something like either a parameter to the subtype =
declaration to specify stringify (or other overloads, perhaps); or alternat=
ely 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: [email protected]
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 dist=
ribution by anyone other than the person for whom it was originally intende=
d is strictly prohibited. If you have received this message in error, pleas=
e contact the sender and delete all copies. Opinions, conclusions or other =
information contained in this message may not be that of the organization.
--_000_01EF6156B387B14E8278ECC376793BE18F579CBBexmb2adoicronca_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html dir=3D"ltr">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style id=3D"owaParaStyle" type=3D"text/css">P {margin-top:0;margin-bottom:=
0;}</style>
</head>
<body ocsi=3D"0" fpstyle=3D"1">
<div style=3D"direction: ltr;font-family: Tahoma;color: #000000;font-size: =
10pt;">Is it possible to define a subtype that will provide a stringify met=
hod?<br>
<br>
I see MooseX::Exception::Base::Stringify that can be provided as a trait fo=
r an attribute, but that gets onerous (and error-prone) when *every* time y=
ou declare an attribute that has "... isa =3D> MyType ..." you=
want to also have "... traits =3D> [qw<code class=3D"perl string">=
{MooseX::Exception::Stringify}</code><code class=3D"perl plain">]
..." applied. It would be much more convenient to have the subtype pr=
ovide the stringify capability. I'm visualizing something like either=
a parameter to the subtype declaration to specify stringify (or other over=
loads, perhaps); or alternately a separate
mechanism (like the way coerce is done) outside the subtype declaration th=
at modifies it to have the overloaded stringify.<br>
</code>
<div><br>
<div style=3D"font-family:Tahoma; font-size:13px">
<p class=3D"western" style=3D"margin-bottom:0cm"><font color=3D"#39793b"><f=
ont style=3D"font-size:9pt" size=3D"2"><span lang=3D"en-US"><b>John Macdona=
ld</b></span></font></font><font color=3D"#39793b"><font style=3D"font-size=
:9pt" size=3D"2"><b><br>
</b></font></font><font style=3D"font-size:8pt" size=3D"1"><span lang=3D"en=
-US">Software Engineer<br>
<br>
</span></font><font color=3D"#39793b"><font style=3D"font-size:9pt" size=3D=
"2"><b>Ontario Institute for Cancer Research</b></font></font><font color=
=3D"#39793b"><font style=3D"font-size:8pt" size=3D"1"><br>
</font></font><font style=3D"font-size:8pt" size=3D"1">MaRS Centre</font></=
p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1">661 University Avenue</font></p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1">Suite 510
<br>
Toronto, Ontario </font></p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1">Canada M5G 0A3</font><font style=3D"font-size:8pt" size=
=3D"1"><span lang=3D"en-US"><br>
</span></font><br>
</p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1"><span lang=3D"en-US">Tel:
</span></font></p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1"><span lang=3D"en-US">Email: [email protected]</span>=
</font></p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font style=3D"font-size:8=
pt" size=3D"1">Toll-free: 1-866-678-6427</font><font style=3D"font-size:8pt=
" size=3D"1"><span lang=3D"en-US"><br>
</span></font><font style=3D"font-size:8pt" size=3D"1">Twitter: @OICR_news<=
/font></p>
<p class=3D"western" style=3D"margin-bottom:0cm"><br>
</p>
<p class=3D"western" style=3D"margin-bottom:0cm"><font color=3D"#0000ff"><u=
><a class=3D"western" href=3D"http://www.oicr.on.ca/"><font style=3D"font-s=
ize:8pt" size=3D"1">www.oicr.on.ca</font></a></u></font><font style=3D"font=
-size:8pt" size=3D"1"><span lang=3D"en-US"><br>
<br>
</span></font><font color=3D"#000000"><font face=3D"Arial, sans-serif"><fon=
t style=3D"font-size:8pt" size=3D"1">This message and any attachments may c=
ontain confidential and/or privileged information for the sole use of the i=
ntended recipient. Any review or distribution
by anyone other than the person for whom it was originally intended is str=
ictly prohibited. If you have received this message in error, please contac=
t the sender and delete all copies. Opinions, conclusions or other informat=
ion contained in this message may
not be that of the organization.</font></font></font></p>
</div>
</div>
</div>
</body>
</html>
--_000_01EF6156B387B14E8278ECC376793BE18F579CBBexmb2adoicronca_--