Welcome! Log In Create A New Profile

Advanced

Precedence discrepancy

Posted by maccaroo 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Precedence discrepancy
March 28, 2006 10:45PM
I'm wondering if anyone else has been confused by the prescribed book's definition of operator precedence.

On page 75, the author says that since * binds stronger than +, + has higher precedence. Now that seems backwards to me, since the operator with the highest precedence should surely be performed first (leaving the result for the other operator).

On the next 2 pages, the author describes yfx as a operator with 1st argument precedence higher than the 2nd, and thus a-b-c should be interpreted as (a-b)-c, i.e. higher predence first! This makes sense, but it contradicts what was said earlier. Right?!?
Re: Precedence discrepancy
April 04, 2006 11:14AM
The terminology is indeed unfortunate, since a higher precedence value in Prolog indicates lower precedence (in normal English). The lowest precedence value in Prolog binds the strongest.

In the specifier yfx, the precedence value of x must be strictly lower than of f, and the precedence value of y must be lower than or equal to that of f. The first argument precedence can be either lower or higher than the second, that doesn't matter. The reason why the reading a - (b - c) is wrong, is because the precedence of b - c is 500 (the precedence of the main operator in the expression b - c) , which is equal to the precedence of the main operator in a - (b - c).
Sorry, only registered users may post in this forum.

Click here to login