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

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

Thread Previous | Thread Next
Tony Cook
August 5, 2021 01:26
Re: Pre-RFC: Real "boolean" SV type
Message ID:
On Wed, Aug 04, 2021 at 03:58:19PM +0100, Paul "LeoNerd" Evans wrote:
> I propose the addition of a new SV type, of SVt_BOOL. Should I write an
> RFC?
> This type will act much like the existing "booleans" of PL_sv_no and
> PL_sv_yes, except its type will remain distinct, so it will be possible
> to distinguish "that SV is a boolean". This is a requirement for
> certain kinds of data serialisation - such as JSON or MsgPack - and may
> be useful for many other purposes too.

I think having some sort of boolean type will be useful for
serialization, I'm not sure svtype is the right place to distinguish

Like PV, PVNV etc (and unlike PVAV, PVIO etc) an SV will tend to get
upgraded as more capabilities are needed from it.

If SVt_BOOL is a small SV type like SVt_IV, can such an SV have magic,
or be blessed?

If SVt_BOOL is a large type like SVt_PVMG, simple booleans will be
paying an extra cost they don't need.

It may need a flag instead.


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