I think I can understand why, too. The logical operators are used to test for success of a constructor. How could that work if $baz = FunkOpera->new(...) or die $! returned sub { $baz or die $!}?Well, the same way as $baz = FunkOpera->new(...) + die $! returning sub {$baz + die $!} I guess.
But the reason || and && aren't overloadable is very different. The reason is that operators aren't the things that carry the overload magic - the operands do. So to know whether an operator acts like it's overloaded, you first need to know the value of all its operands. This is not a problem for most operators, as it needs to know the value of both operands before know what its value will be. But || and && act differently - their left operand is evaluated to find out whether or not to evaluate its right operand.
In reply to Re: FunkOpera: Abstracting Perl Operators
by Anonymous Monk
in thread FunkOpera: Abstracting Perl Operators
by Zaxo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |