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

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

Thread Previous | Thread Next
From:
Ovid via perl5-porters
Date:
December 18, 2021 14:16
Subject:
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
811926793.1870601.1639836959501@mail.yahoo.com
On Saturday, 18 December 2021, 13:21:03 CET, Oodler 577 via perl5-porters <perl5-porters@perl.org> 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.

Best,
Ovid
-- 
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/. 

Buy my book! - http://bit.ly/beginning_perl

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