Damien Neil wrote:
> On Wed, Sep 20, 2000 at 04:12:09AM -0000, Perl6 RFC Librarian wrote:
> > Add null() keyword and fundamental data type
>
> I think that this is better done as a special overloaded object used
> by database modules which wish to implement SQL-style tri-state logic.
It could be done as an overloaded object. You'd have to be able to overload all
the operators, both numeric and string.
> Given that making overloaded objects fast appears to be a major
> design goal of Perl6, there should be no serious performance problems
> to this.
And it would, indeed, have to be fast.
> The one thing which this requires that Perl5 does not have is the
> ability to overload the defined() operation on an object.
And what about overloading the ternary ?: operator? Of course, that one can be
avoided.
> Other
> than that, the following code produces a usable null object:
>
> package Null;
>
> use overload '""' => sub { undef },
> bool => sub { undef },
> '0+' => sub { undef },
> nomethod => sub { bless {} };
>
> sub null() { bless {}; }
>
> print " 1 + 1 = ", ( 1 + 1), "\n"; # 1 + 1 = 22
> print "null + 1 = ", (null + 1), "\n"; # null + 1 =
> print " 1 + null = ", ( 1 + null), "\n"; # 1 + null =
> print "null + null = ", (null + null), "\n"; # null + null =
>
> print "defined(null) = ", defined(null), "\n"; # defined(null) = 1 (error)
Not usable, I get lots of "Use of uninitialized value in print" warnings, and do
not have use strict.
> I don't think that we would be well served by confusing the state of
> truth in core Perl any further than it is now, especially when the
> desired functionality does not need to be in the core.
>
> Incidentally, I'm surprised that DBI hasn't added an option to use
> an overloaded null object, if this feature is in demand.
Performance.
--
Glenn
=====
Even if you're on the right track,
you'll get run over if you just sit there.
-- Will Rogers
____________NetZero Free Internet Access and Email_________
Download Now http://www.netzero.net/download/index.html
Request a CDROM 1-800-333-3633
___________________________________________________________