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

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

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
December 19, 2021 10:13
Subject:
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
9b4a71a2-fa49-5519-f57e-99f02bd69468@rtij.nl
Op 19-12-2021 om 00:18 schreef Paul "LeoNerd" Evans:
> I think if you were to present this if/else code to anyone not
> intimately familiar with this three-value logic idea, and tell them
> there is a value you can put in $foo which makes neither branch
> execute, they would look at you strangely and consider you quite mad.
>
> There may be a Lewis Carroll quote applicable here...


My thoughts exactly. But even worse, this will introduce bugs in 
existing code, unless you need a feature flag for this to happen, in 
which case code without the feature flag (for instance a library called 
from code that uses unknown) running against this situation probably 
should die. Silently skipping both branches of an if is insane if not 
guarded by a feature flag and only slightly less insane with.

So what to do? Make such code die? But that reintroduces the original 
problem, then we have a new singleton value which avoids many calls to 
defined(), just to replace them with calls to is_unknown() (in other 
places, but still).

I do think there must be a satisfactory answer to this question before 
we can proceed with implementation. It does not have to stand in the way 
of an RFC.


HTH,

M4





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