"David L. Nicol" wrote:
>
> What if perl6 kept it as the default, but allowed any class
> to override the object->BOOLEAN accessor which will return
> um, a special TRUE and FALSE which only make sens in boolean
> contexts?
>
> Hopefully someone else can come up with a good example.
This is actually an excellent point, and it has direct bearing on some
of my RFC's for object embedding.
Here's an example:
$count = get_data_object; # object, sets $count->NUMBER = 0
# does this test the existence of $count, or the number
# stored in $count->NUMBER, or ???
if ( ! $count ) {
$count++; # $count->NUMBER++
}
Here, having a $count->BOOLEAN which was just a reference to
$count->NUMBER would do the trick.
Mind if I use (steal?) your BOOLEAN idea and put it in an upcoming RFC
on "True Polymorphic Objects"?
Cheers,
Nate