Dan Sugalski writes:
> It's possible, for example, for a tied/overloaded/really-darned-strange 
> variable to look true but still be false. If you do:
> 
>    $foo = $bar || $baz;
> 
> and both $bar and $baz are objects, the 'naive' way is to make $foo be 
> $bar. But it's distinctly possible that $bar really should be treated as a 
> false value and $baz be used instead. Why? Dunno. Serious hand-waving here. 
> (And yes, I know that's a danger sign... :) But I don't see any reason to 
> preclude the possibility.

You can do that right now in perl5, by using overload.pm and supplying
a 'bool' method.

An application might be when your object represents an array and you
want the boolean context of your object to report whether it has data
in it or not, to facilitate:

  if ($pdl) {
     # do something if the $pdl has data in it
  }

Nat

Reply via email to