=head1 TITLE New 'tristate' pragma to allow undef to take on NULL semantics =head1 VERSION Maintainer: Nathan Wiger Date: 23 Sep 2000 Last Modified: 29 Sep 2000 Mailing List: perl6-language@perl.org Number: 275 Version: 2 Status: Frozen =head1 ABSTRACT RFC 263 proposed the introduction of a C keyword for introducting tristate logic into Perl 6. However, that was abandoned in favor of the approach specified here, a C pragma. =head1 DESCRIPTION The C pragma allows for undef to take on the RDBMS concept of C, in particular: 1. Any operation between a NULL and any other value results in NULL 2. Any comparison between a NULL and any other value is false 3. No NULL value is equal to any other NULL 4. A NULL value is neither defined nor undefined The C pragma is lexically scoped, so that it obeys code blocks: $a = undef; $b = 1; $c = $a + $b; # 1 { use tristate; $d = $a + $b; # undef } $e = $c + $d; # 1 In addition, the C builtin is overloaded as an "is not null" operator under the pragma: use tristate; $name = undef; die "Badness" unless defined $name; # $name is not null This simplifies C, actually: C will always return false if C<$x> is C, regardless of the C pragma. For more details on theoretical issues, please see the references or RFC 263. =head1 IMPLEMENTATION No idea, too burned out. =head1 MIGRATION None, unless some fool has a custom C module that they wrote to navigate the tristate area of New York, New Jersey, and Connecticut. But that should be C anyways. =head1 REFERENCES RFC 263: Add null() keyword and fundamental data type http://www.sitelite.nl/mysql/manual_Problems.html#IDX666 http://www.unb.ca/web/transpo/mynet/mtx19.htm#r2