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

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

Thread Previous | Thread Next
Darren Duncan
December 18, 2021 23:02
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
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 

> 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About