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

Re: Types in Cor (and Perl)

Thread Previous | Thread Next
Darren Duncan
July 31, 2020 23:52
Re: Types in Cor (and Perl)
Message ID:
On 2020-07-31 3:31 p.m., Curtis Jewell wrote:
> On Sun, Jul 12, 2020, at 19:52, Dave Rolsky wrote:
>> 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.
> Which is why I (personally) would want to have a Str type that accepts objects that overload AND a StrictStr type that does not. The ability to allow or reject that as desired would be nice to have.

Really we should just be stealing useful stuff from Raku here.

What we want is 2 distinct categories based on classes and roles.

If someone wants "any object that can stringify" then they choose the Stringy 
role as their type.

If someone wants strictly the built in string type, then they choose the Str class.

Its as simple as that.

And I personally would want to use the strict type by default most of the time.

-- Darren Duncan

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