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

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

Thread Previous | Thread Next
Martijn Lievaart
December 19, 2021 10:13
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
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.



Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About