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

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

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
August 5, 2021 11:56
Subject:
Re: Pre-RFC: Real "boolean" SV type
Message ID:
20210805115623.GM11066@etla.org
On Thu, Aug 05, 2021 at 01:35:19PM +0200, Salvador Fandiño wrote:
> 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.

I think that this is relevant discussion for an RFC proper, not this Pre-RFC
thread. Thanks for raising this potential problem early.

Consensus seems to be that having boolean values that know that they are
boolean values is worth an RFC. How we best implement it isn't obvious
without experimenting, and discovering the drawbacks of any approach.

Nicholas Clark


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