On 10 Sep 2001, at 9:57, da Silva, Joe wrote:
I'm not good on the jargon, but is "-2" really a unary "-" and a number (2), or is "-2" a number in itself (ie. the sign is not an operator)?
The Extended Pascal standard, section 6.8.1, "Expressions, General," says that the expression "-2" is a simple-expression, which is defined as a sign followed by a term. So "-" is the sign, and "2" is the term. The standard therefore treats any expression with a leading sign as a unary operator applied to an unsigned expression.
To continue, "-2 pow 2" is parsed as the sign "-" and the term "2 pow 2". The term is parsed as a factor, which is defined as a primary, followed by an exponentiating-operator (in this case, "pow"), followed by another primary. "2" is a primary because primaries may be unsigned-constants.
This is what Maurice suggested in his second posting, and is the natural/intuitive interpretation of "-2".
Unfortunately, "intuitive interpretations" don't count when a standard says otherwise.... :-)
-- Dave