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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|