On Thu, Mar 27, 2008 at 01:08:43PM +0100, TSa wrote:
> TSa wrote:
>> Another good use of the dot forms is to get a single character
>> form to tighten precedence: $x**3! != $x**3.! == $x**(3!).
> BTW, is the dot form only available for postfix or for infix
> as well? I.e. 3 * 2 == 3.*(2)?
Only postfix. (And we already use .* for something else.) You can
probably get away with 3.infix:<*>(2) though.
However, note also that operators are intended to be dispatch
using multiple dispatch, not single. Multiple dispatch allows the
language to defined the operator without getting the object involved.
Single dispatch has to rely on the semantics of the object itself to
determine the meaning of a method. This becomes important when we
have objects from outside of Perl. $a + $b is always addition under
multiple dispatch, but $a.infix:<+>($b) might do concatenation if $a
is a foreign object from a language that (mis)treats + that way.