[top-posting] I should add that what would make this even more interesting if we could do this: use feature '3vl_undef'; # terrible name And all undef values in the current lexical scope would use 3vl logic instead of 2vl. This would like "use strict for undef". I firmly believe many bugs could be avoided this way. Best, Ovid -- IT consulting, training, specializing in Perl, databases, and agile development http://www.allaroundtheworld.fr/. Buy my book! - http://bit.ly/beginning_perl On Saturday, 18 December 2021, 09:57:32 CET, Ovid via perl5-porters <perl5-porters@perl.org> wrote: Hi there, As most of you know, "undef" values often cause all sorts of interesting bugs in Perl. I wrote https://metacpan.org/pod/Unknown::Values to address this. Instead of the 2VL that undef uses, it uses Kleene's traditional 3VL (three-value logic) akin to SQL's NULL. Basic usage looks like this: use Unknown::Values; my $value = unknown; my @array = ( 1, 2, 3, $value, 4, 5 ); my @less = grep { $_ < 4 } @array; # (1,2,3) my @greater = grep { $_ > 3 } @array; # (4,5) my @underpaid; foreach my $employee (@employees) { # this will never return true if salary is "unknown" if ( $employee->salary < $threshold ) { push @underpaid => $employee; } } I've also written about this here: http://blogs.perl.org/users/ovid/2013/02/three-value-logic-in-perl.html I've always thought this belongs directly in a programming language, but never suggested this because I assumed there would be no interest To my surprise, brian d foy suggested it be in the core (https://twitter.com/briandfoy_perl/status/1471684211602042880) He wrote: "Unknown::Value from @OvidPerl looks very interesting. These objects can't compare, do math, or most of the other default behavior that undef allows. This would be awesome in core." Would there be interest? Best, Ovid -- IT consulting, training, specializing in Perl, databases, and agile development http://www.allaroundtheworld.fr/. Buy my book! - http://bit.ly/beginning_perlThread Previous | Thread Next