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

Re: Pre-RFC: `unknown` versus `undef`

Thread Previous | Thread Next
From:
Darren Duncan
Date:
December 18, 2021 23:02
Subject:
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
251f822a-03fa-2ace-2cc8-ceeef3189a14@darrenduncan.net
On 2021-12-18 12:05 p.m., Nicholas Clark wrote:
> Likewise:
> 
>      $result = $foo ? bar() : baz();
> 
> I had thought - ternary, where $foo is unknown - can't take the true side,
> can't take the false side, so logically surely it short-circuits to assign
> $result as unknown.

I would agree with that.

> But then that means that to be consistent with that, here:
> 
>     if ($foo) {
>         bar();
>     } else {
>         baz();
>     }
> 
> if $foo is unknown we can't enter either block

Yes, and that's the answer.  I would argue that when given an unknown input the 
effect of this block would be a no-op.

Speaking more generally, the effect of unknown could be what Perl does with an 
empty statement block, which as far as I recall is do nothing and return 
undef/unknown.

> So an RFC would have to go down all these paths, to figure out how to make
> a language that is consistent in how it handles unknown in all places?

Yes we do.

-- 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