why bother with operator precedence

Cliff Joslyn cjoslyn at bingvaxu.cc.binghamton.edu
Wed Mar 28 12:38:27 AEST 1990


Since operator precedence in C is relatively arbitrary and there are
*many* operators, I let my students use an operator chart on exams
(along with an ASCII chart and other similar collections of detailed
information that no one should need to memorize).  Then I might give
them one of the monster expressions we've seen and ask them to provide a
parsing, along with an evalution of the type, size, and value of each
sub-expression.  In code, I criticize both over-parenthesization and
under-parenthesization as I see fit.  This seems to accomplish both ends
of teaching precedence while not being dogmatic about it. 

-- 
O------------------------------------------------------------------------->
| Cliff Joslyn, Cybernetician at Large, cjoslyn at bingvaxu.cc.binghamton.edu
| Systems Science, SUNY Binghamton, Box 1070, Binghamton NY 13901, USA
V All the world is biscuit shaped. . .



More information about the Comp.lang.c mailing list