Gentlemen,
I don't quite get what all of you are talking about here.
Peter's test script should work completely different if Oxygen's parentheses
() are supposed to fulfill their intended purpose.
For example, the following conditional
if ((a = 2.0) < 2.0) // ML: C syntax properor its equivalent Oxygen conditional
if (a = 2.0) < 2.0 ' ML: O2 syntax assumed hereinbelow for simplicitywould be analyzed in the C language as follows.
The
() operator has the highest scope precedence in a statement. The sub-expression within the innermost parentheses (luckily there's only one nesting level in our case) is evaluated or executed the first. Here
= is an assignment that makes
a equal to
2.0 and this assignment is the very first thing the language does when evaluating the entire expression.
Further, C's parentheses also return their own temporary value which is equal to a result of the sub-expression that they immediately embrace. The result may be either arithmetical (as in our case above) or stringified (for example, a string produced as a result of concatenating several strings into one). Our sub-expression evaluates to
2.0, math-wise. This temporary result is valid for the purposes of boolean evaluation in the given
if-block.
Whereby the initial expression may be reduced to simple
if 2.0 < 2.0 ' ML: ditto about syntaxwhich obviously evaluates to
false. That is exactly why we shouldn't see the entire
if-block print
anything at all apart from doing at least one more useful thing that the programmer evidently wanted it to do, which was to assign
2.0 to the variable
a.
From this standpoint, the following code:
sys a
iF a=1.0+1.0 = 2.0
print "1.0+1.0 = 2.0 (TRUE ==> should print)"
End iF
iF a=1.0+1.0 >= 2.0
print "1.0+1.0 >= 2.0 (TRUE ==> should print)"
End iF
iF (a=2.0) > 2.0
print "2.0 > 2.0 (FALSE ==> should NOT print at all!)"
End iF
iF (a=2.0) <> 2.0
print "2.0 <> 2.0 (FALSE ==> should NOT print at all!)"
End iF
iF (a=2.0) < 2.0
print "2.0 < 2.0 (FALSE ==> should NOT print at all!)"
End iF
Print "okay"
does really strange things which I am inclined to regard as
undefined behavior of Oxygen's parentheses.
It seems like we should ask Charles to revise his design decision again if he really wants Oxygen's parentheses to behave
conventionally, because the above is very likely an outstanding bug.
Regards,