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

Re: Pre-RFC: Real "boolean" SV type Nicholas Clark <nick@ccl4.org>

Thread Previous | Thread Next
From:
Salvador Fandiño
Date:
August 5, 2021 11:35
Subject:
Re: Pre-RFC: Real "boolean" SV type Nicholas Clark <nick@ccl4.org>
Message ID:
7ff5150d-0480-db03-9e59-92ab045326aa@gmail.com
On 5/8/21 12:58, Paul "LeoNerd" Evans wrote:

> I don't yet have a good thought about "no", but since PL_sv_yes carries
> its own stringification PV, it's possible that sv_setsv could notice
> it's that special value and store it as-is, with SvLEN == 0, into the
> target. So it's now possible to distinguish any true bool value, by
> 
>    SvIV(sv) == 1 && SvPVX(sv) == SvPVX(&PL_sv_yes)

That would impede one for having boolean dualvars.

Programmers may want to have booleans that stringify as True/False, T/F, 
Yes/No, 1/0, or the current 1/"".

Actually, I would say the current PL_sv_no stringification ("") is not 
the one the programmer needs in most cases.

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