develooper Front page | perl.moose | Postings from June 2014

Re: coerce a sub-subtype

Thread Previous | Thread Next
From:
Karen Etheridge
Date:
June 16, 2014 20:07
Subject:
Re: coerce a sub-subtype
Message ID:
20140616200723.GP55364@tequila
On Mon, Jun 16, 2014 at 07:41:29PM +0000, John Macdonald wrote:
> In general, though, having a way of inheriting subtypes could be potentially a big saving in this sort of case.

This would be a really nice feature to have in MooseX::Types - no one's
made this happen yet though, sadly. (Patches welcome!) :)
Also, Types::Tiny does have an option to support this already.

I'd strongly suggest avoiding declaring named types using
Moose::Util::TypeConstraints though, because such types are global (as are
their coercions), which can cause nasty action-at-a-distance errors. You
can get around this problem by declaring types only as local lexicals, e.g:

my $type = subtype as ...;

Thread Previous | Thread Next


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