Kealey, Martin, wrote:
> Nice idea; introduces one particular ambiguity though: would
>
>  $m ** $n
>
> then be
>
>  pow($m, $n)
>
> or
>
>  pow($n, $m)
>
> ?

Neither.  As with the reducing meta-operator, you would need to have
the ability to define an operator that takes precedence over a meta'd
operator, for those cases where a particular combination of symbols
has a meaning that is either more broad or incompatible with what the
replication meta would supply.  Conveniently, '**' is one such
operator.  To whit:

In '$count *op $value' and '$value op* $count', $count must be an
unsigned integer of some sort: it's nonsense to replicate an operation
half of a time, or negative two times, or i times.  However, '$base **
$power' places no such restrictions on either $base or $power; thus,
it needs to be separately defined.  The fact that its behavior
coincides with a replicator appended to a multiplication operator when
the power is an unsigned integer is merely a convenient coincidence as
far as the compiler is concerned.

That said, there _is_ still some potential ambiguity if you have
operators that begin or end with '*'.  For instance: let's say that
you want to apply replication to exponentials: does '$m *** $n' mean
'$m repetitions of $n ** $n', or does it mean '$m ** $m, repeated $n
times'?  The longest-token rule resolves this dilemma in favor of the
latter.

-- 
Jonathan "Dataweaver" Lang

Reply via email to