develooper Front page | perl.perl5.porters | Postings from December 2019

Re: Type and Value Constraints and Coercions

Tony Cook
December 3, 2019 00:57
Re: Type and Value Constraints and Coercions
Message ID:
On Fri, Nov 29, 2019 at 10:18:57AM +0000, Toby Inkster (TOBYINK) wrote:
> This is a reply to Dave Mitchell's email, but it will probably get
> threaded badly as I've only just subscribed to perl5-porters and don't
> have the original email to click "reply" on.
> This is all pretty over-engineered. It can be simplified to something
> that would work well with existing type implementations such as
> MooseX::Types, MouseX::Types, Type::Tiny, and Specio.

If you haven't see them, Toby's blog postings on Type::Tiny are worth reading:

> Second, define these:
>   use Scalar::Util;
>   sub UNIVERSAL::check {
>     my ($class, $object) = @_;
>     blessed($object) && !blessed($class) && $object->DOES($class);
>   }
>   sub UNIVERSAL::get_message {
>     my ($class, $value) = @_;
>     "$value is not $class";
>   }
> Third, nothing. There is no third.

I think is should be distinct from isa, so I don't think the above is needed.

Tony Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About