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 19, 2021 11:34
Subject:
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
6feacc4d-8b89-bc3a-9853-7473d8c86e66@darrenduncan.net
On 2021-12-19 2:53 a.m., Martijn Lievaart wrote:
> Op 19-12-2021 om 11:48 schreef Darren Duncan:
>> Well the other reasonable solution is to treat the pair as "if the expression 
>> result is true" and "if the expression result is anything else".  I actually 
>> thought of proposing that and then I didn't.
>>
>> However, doing that means these 2 things will behave differently in the 
>> presence of unknown where they wouldn't otherwise:
>>
>>   if ($x) {
>>     foo();
>>   }
>>   else {
>>     bar();
>>   }
>>
>>   if ($x) {
>>     foo();
>>   }
>>   if (!$x) {
>>     bar();
>>   }
>>
> I like it from a conceptual point of view. It feels right. It feels correct. But 
> only for new code that is written with this 3VL in mind. Otherwise I think it 
> will open a can of bugs in existing code, so that probably should still die.

I still think, however, my original proposal of neither if nor else running when 
an unknown is input, is probably more correct and consistent with the wider context.

That interpretation means both of the above examples behave the same as each 
other, same as would be the case under 2VL.

A stronger supporting point is that the do-nothing answer is more consistent 
with the examples Ovid gave about desired behavior for "grep" or such, which is 
that unknown are omitted from the result no matter whether the grep condition 
tests for truthiness or falseiness, which is also the same as how SQL WHERE 
behaves with NULL.

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