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

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

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
August 5, 2021 10:42
Subject:
Re: Pre-RFC: Real "boolean" SV type
Message ID:
20210805114221.2aea8a82@shy.leonerd.org.uk
On Thu, 5 Aug 2021 07:29:15 +0000
Nicholas Clark <nick@ccl4.org> wrote:

> On Thu, Aug 05, 2021 at 11:26:07AM +1000, Tony Cook wrote:
> > I think having some sort of boolean type will be useful for
> > serialization, I'm not sure svtype is the right place to distinguish
> > them.
> > 
> > Like PV, PVNV etc (and unlike PVAV, PVIO etc) an SV will tend to get
> > upgraded as more capabilities are needed from it.
...
> > It may need a flag instead.  
> 
> It can't be implemented as a type.
> 
> Much like the "was this originally an integer/was this originally a
> string" problem can't also be implemented as a type.
> 
> In that, if you need to bless a boolean, then it has to be SVt_PVMG.
> 
> And for certain operations, the *value* needs to pass through a PVLV
> without loosing it's "I'm a boolean"-ness. I think tied hashes; but
> certainly this;

Ahyes; you're both right of course, for exactly the same reasons as my
previous suggestion about SVt_PV_was_IV vs SVt_IV_was_PV. You'd think
after that first one I'd learn, but no... ;)

I'll mention that in the RFC and point out it really does need a flag -
SvBOK() or somesuch?

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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