develooper Front page | perl.perl5.porters | Postings from August 2021

Re: Pre-RFC: Real "boolean" SV type

Thread Previous | Thread Next
From:
Darren Duncan
Date:
August 6, 2021 00:25
Subject:
Re: Pre-RFC: Real "boolean" SV type
Message ID:
2c0e3549-d73c-acfe-81a4-029f7fdfde31@darrenduncan.net
On 2021-08-05 5:10 p.m., Yuki Kimoto wrote:
> 2021-8-5 19:58 Paul "LeoNerd" Evans wrote:
> 
>     But now we're getting into the weeds of implementation. I think my
>     original discussion has demonstrated that people do feel a need for
>     this ability - so I'll write the RFC and we can worry about the "how"
>     later
> 
>   I think what people really want is a Boolean standardization of JSON.
> 
> Perl has no type in the language specification, however it is useful to have a 
> flag that it is currently a Boolean value.
> 
> true and false are functions to create bool value, not bool type.
> 
> I think weird edge cases will appear, however I think it's possible to reduce them.

What's needed is a boolean type whose values are disjoint from all numbers and 
all strings, the latter 2 also being disjoint from each other.

One needs to be able to round-trip losslessly, which would only happen if these 
were disjoint.

A JSON false or true converted to Perl and back to JSON needs to still be JSON 
false or true respectively.

A JSON number 0 or 1 converted to Perl and back to JSON needs to be a JSON 
number 0 and 1.

A JSON empty string '' or strings '0' or '1' need to convert to Perl and back to 
JSON as those same strings.

And so on.

If there wasn't a disjoint boolean type and Perl functions false/true just 
generated numbers or strings, then we wouldn't have round-tripping, which means 
we LOSE INFORMATION.

So not losing information is what is desired.

-- Darren Duncan

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