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

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

Thread Previous | Thread Next
Ovid via perl5-porters
December 18, 2021 14:16
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
On Saturday, 18 December 2021, 13:21:03 CET, Oodler 577 via perl5-porters <> wrote:

> 1. in DBI:: modules, NULL is equivalent to undef

I wish that was true, but the behavior of NULL and undef are very different.

I've thought about writing a component for this for DBIx::Class, if `undef` values returned `unknown` instead, then the semantics of your Perl would behave much closer to the semantics of the database, eliminating another aspect of the object-relational impedance mismatch. You couldn't catch all of the cases, but there are many you would.

Heck, can we even force a warning on `my $foo; $foo++`? I don't think so because I thought that was special-cased in Perl. `my $foo = unknown; $foo++` issues a warning we might often like to see.

I'm not saying that `unknown` is always superior (and overloaded objects are *slow*), but in most code dealing with undef that I see, 3VL makes the code both shorter and more correct.

I admit that this would probably make Perl radically depart from some other languages, but I'm unconvinced that this would be a Bad Thing.

IT consulting, training, specializing in Perl, databases, and agile development 

Buy my book! -

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