'&&' seems to get nervous in certain conditions

Using && in combination with arrays may lead to unwanted results.


I had a 'if *<*i>0 && py>0 && py[i-1]>0*>*' clause which failed from time to time until I changed the code to 'if *<**<*i>0*>* && *<*py>0*>* && *<*py[i-1]>0*>**>*'...


PS: as the forum does not like standard brackets I have replaced them by *<* and *>*
PSS: not easy to read now, I know
  • Is it possible that this is a precedence issue?

    The Programmers Guide has a list of operators and their precedence, but it doesn't list the subscript operator. It doesn't list the increment and decrement operators (++x and --x), unary plus/minus (+x, -x), member access (obj.member), the ternary operator (x ? y : z), or the throw and assignment operators either, so it seems the table is incomplete. I don't believe MonkeyC supports using computed assignment expressions as subexpressions, but if it does, they should be in that table too.

    Most languages put the subscript operator very near the top of the precedence list. It seems it should be treated similarly for MonkeyC arrays and dictionaries as well.

    If it is not a precedence issue, I'm curious to see what is going on here. Do you have a testcase?