develooper Front page | perl.perl5.porters | Postings from June 2020

Re: Encoding WAS Re: Announcing Perl 7

Thread Previous | Thread Next
Leon Timmermans
June 30, 2020 15:39
Re: Encoding WAS Re: Announcing Perl 7
Message ID:
On Tue, Jun 30, 2020 at 5:55 AM Darren Duncan <> wrote:
> - An integer, meaning an IV.
> - A floating-point number, meaning an FV.
> - A string of octets, meaning one kind of SV.
> - A string of characters, meaning a different kind of SV.
> I for one would love to have a very easy way to introspect, in a very strict
> manner, exactly which one of these 4 we have.

What we would need is types based on intention; "is it text or a
binary". Internal encoding is entirely irrelevant for that.

Problem is, in all old Perl code this distinction is not being made,
so the value you'd get is unreliable. Effectively this is very much a
"this breaks all of CPAN" kind of change.

I get why you want this 100%, but I'm not seeing any solution for it :-/.

> Ideally there would be a disjoint representation of a pure boolean as well, that
> is distinct from 0 or 1 or "" or so on, like any other good modern language has.

> A key business requirement I have is that I can write code that takes a generic
> Perl scalar as input and do different things depending on which type it is in
> the strict sense, because it can distinguish them without any extra metadata not
> in the scalar itself.  I can workaround gaps in this by supplying metadata
> externally, but that is a more verbose and slower user experience than it being
> natively part of Perl scalars.

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