[% setvar title New 'tristate' pragma to allow undef to take on NULL semantics %]
Note: these documents may be out of date. Do not use as reference! |
To see what is currently happening visit http://www.perl6.org/
New 'tristate' pragma to allow undef to take on NULL semantics
Maintainer: Nathan Wiger <nate@wiger.org> Date: 23 Sep 2000 Last Modified: 29 Sep 2000 Mailing List: perl6-language@perl.org Number: 275 Version: 2 Status: Frozen
RFC 263 proposed the introduction of a null
keyword for introducting
tristate logic into Perl 6. However, that was abandoned in favor of the
approach specified here, a tristate
pragma.
The tristate
pragma allows for undef to take on the RDBMS concept of
NULL
, 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 tristate
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 defined
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 undef
, actually: defined($x)
will always return
false if $x
is undef
, regardless of the use tristate
pragma.
For more details on theoretical issues, please see the references or RFC 263.
No idea, too burned out.
None, unless some fool has a custom tristate
module that they
wrote to navigate the tristate area of New York, New Jersey, and
Connecticut. But that should be Tristate
anyways.
RFC 263: Add null() keyword and fundamental data type
www.sitelite.nl#IDX666
www.unb.ca#r2