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

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

Thread Previous | Thread Next
From:
David Cantrell
Date:
August 5, 2021 14:42
Subject:
Re: Pre-RFC: Real "boolean" SV type
Message ID:
20210805142124.GA30413@bytemark.barnyard.co.uk
On Wed, Aug 04, 2021 at 03:30:35PM -0700, Aaron Priven wrote:

> I don???t have a problem with the proposal per se, but it???s hard for
> me to believe that inferring what type a value should be from its
> initial assignment is going to be reliable.
> 
> Surely there???s a lot of extant code like
> 
>   if ($condition) {
>      $flag = $x eq $y;
>   } else {
>      do_something();
>      $flag = 1;
>   }
>   $count+= $flag;
> 
> Is $flag a boolean or an integer? 

I'd expect that It Depends.

But I'd expect $count to be an integer, because + always returns a
number, just like it would be if you say this:

    $car_contents = '11 clowns';
    $count += $car_contents;

-- 
David Cantrell | Pope | First Church of the Symmetrical Internet

    Deck of Cards: $1.29.
    "101 Solitaire Variations" book: $6.59.
    Cheap replacement for the one thing Windows is good at: priceless
        -- Shane Lazarus

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