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

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

Thread Previous | Thread Next
Paul "LeoNerd" Evans
August 5, 2021 10:42
Re: Pre-RFC: Real "boolean" SV type
Message ID:
On Thu, 5 Aug 2021 07:29:15 +0000
Nicholas Clark <> 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      |  |

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