[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Prefix



Kragen Sitaker wrote:
> 
>...
> 
> That's what I thought, too, but then I examined some expressions.
> 
> In ((2 - 3) * (4 + 1)) / (11 + 3), the / is separated from its child
> operators (* and the second +) by six and two tokens respectively, for
> a sum of eight.  * is separated from its child operators by two and
> two tokens, for a total of four.  The other three operators are
> adjacent to their operands, so we have a total of only twelve
> intervening tokens.

I would say that "/" is separated on the left from its numerator
expression by 0 tokens and on the right by 0 tokens. The left expression
is a multiplication. The asterisk is separated on the left by 0 tokens
and on the right by 0 tokens. etc. If distance were measured by
proximity to the "child operator" then people would find it much easier
to read this:

((a + b + c + d + e + f - g ) * 4) / 3

rather than this:

(4 * (a + b + c + d + e + f)) / 3

But really it is roughly the same, because you need to understand the
whole expression, not the single top-most operator. 

 Paul Prescod