Is it the underlying statement that is ambiguous, or is it that we haven't sufficiently defined the syntax?
In computer programming (and, IIRC, in mathematics), precedence is defined. The statement x=4*3+7; isn't ambiguous because multiplication takes precedence over addition (in most languages).
Too, you can always use parentheses to override "natural" precedence. In the statement x=4*(3+7);, x takes the value 40, not 19, because sub-expressions in the innermost parentheses (only one set in this example) are interpreted (or compiled :) ) first. Liberal use of parentheses in programming to eliminate ambiguity is considered virtuous, as not everyone remembers the precedence of operators in a language, and some may switch between several languages with different rules.
The statement Q1Q2S would always be interpreted unambiguously and in the same way by a compiler (granted, different compilers might interpret it differently, but any given compiler would always handle the same way).
no subject
Date: 2008-09-21 12:50 am (UTC)In computer programming (and, IIRC, in mathematics), precedence is defined. The statement x=4*3+7; isn't ambiguous because multiplication takes precedence over addition (in most languages).
Too, you can always use parentheses to override "natural" precedence. In the statement x=4*(3+7);, x takes the value 40, not 19, because sub-expressions in the innermost parentheses (only one set in this example) are interpreted (or compiled :) ) first. Liberal use of parentheses in programming to eliminate ambiguity is considered virtuous, as not everyone remembers the precedence of operators in a language, and some may switch between several languages with different rules.
The statement Q1Q2S would always be interpreted unambiguously and in the same way by a compiler (granted, different compilers might interpret it differently, but any given compiler would always handle the same way).