develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Types in Cor (and Perl)

Thread Previous | Thread Next
Dave Rolsky
July 13, 2020 01:52
Re: Types in Cor (and Perl)
Message ID:
On Sun, Jul 12, 2020 at 8:05 AM Ovid via perl5-porters <> wrote:

> I know very little of Perl's internals or what this would mean. For Cor
> V1, I'd be tempted to go with attributes and Types::Standard (
> :isa(ArrayRef[Int])), but I strongly suspect that it will conflict with
> David's work, and it won't provide the type safety one would expect.

Rather than just borging Types::Standard directly I think it's worth
thinking more about what a type system might look like. One huge issue I
have with Types::Standard is that it just copies the mistakes of Moose, so
let's not copy them into the core!

Specifically, I think having a `Str` type that doesn't accept objects which
overload (and similar for other types) is a huge mistake. Of course, once
you start thinking about this you start going down the rabbit hole of
stringification and what it means for something to stringify, since _every_
type in Perl can stringify, but maybe not usefully. Then you start thinking
about things like roles and have a `Stringies` role or something like that.

Is that a road worth going down? I really can't say. But at the very least
it's worth thinking about, and if the core were to explicitly reject that,
it's worth documenting.


Dave Rolsky

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