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

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

Thread Previous | Thread Next
From:
Darren Duncan
Date:
August 5, 2021 06:42
Subject:
Re: Pre-RFC: Real "boolean" SV type
Message ID:
778ad48a-8cb4-0912-961b-f613f4249a61@darrenduncan.net
On 2021-08-04 11:28 p.m., Ovid via perl5-porters wrote:
> Very much support this idea.
> 
> One question, how would it handle this annoyance?
> 
>     #!/usr/bin/env perl
> 
>     use strict;
>     use warnings;
> 
>     my @list    = map { rand(50) } 1 .. 10;
>     my $matches = 0;
>     for (@list) {
>        $matches += $_ > 25; # ???
>     }
>     print "Matches = $matches\n";
> 
> Yes, that's an abuse, but it's the kind of crud we see in the wild (and it 
> doesn't throw any warnings);

If my previous suggestion is followed, then the numeric operator += would cause 
the result of "$_ > 25" to be cast as an integer which for the boolean true 
would be 1, and so the behaviour would be the same as in prior Perl versions. -- 
Darren Duncan

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