PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Computer Folklore

operator precedence was: Where should the type information be Keywords


VPN Service Provider

Where should the type information be 141
On Wed, 30 Mar 2005 22:53:54 -0700, Steve Well, yes, they are different, and do different things. The first is a conditional operator...

on changing the operator precedence in C

The more cautious approach would be to first deprecate the old syntax; then make it non-standard, i.e., the standard syntax would be (a subset of?) the intersection of old and new syntax (i.e., parentheses required for those combinations where the precedence changes); finally introduce the new syntax.

However, I think that a syntax that requires parentheses even when you could make them redundant with some operator precedence ordering is often better than a syntax that does not require them. For few combinations, the operator precedence and "buttociativity" is either so obvious or so well-trained that the program cannot be misread.

That includes even operations that we were taught in school, like division (because the operator in programming has a different syntax than the one in school); even third-year computer science students are not sure what a-b*c means; and many cases involving other operators are not at all obvious (e.g., the relative precedence of AND and OR).

So, the right way to deal with operator grouping is to require parentheses in general. Allowing to leave the parentheses away should be the exception rather than the rule, and it should only be used in the following cases:

Where should the type information be 140
Herman, YES, they are right in the spec, along with the different operators to be used on them. && is fundamentally different than &. I am just proposing that the compiler complain when...
Where should the type information be 143
On Thu, 07 Apr 05 11:54:40 GMT Heisenberg rules :) But seriously - it's a given that more uses get found...

- The grouping makes no difference, e.g., because the operators involved are buttociative; e.g., a+b+c.

- The grouping has been taught in school for a long time, e.g., a-b-c, a+b*c.

Where should the type information be 142
Until a critical number of people get the gear and are allowed to play with it to see what kinds of things it can be used for...

- The grouping is intuitive for some good reason (be careful with that). One reason might be type rules; e.g, if + produces ints, = takes ints and produces bools, and AND takes bools, the only sensible way to interpret a+b=c+d AND e+f=g+h is determined by the type rules. Note that if you also have, e.g., a type rule allowing bool=bool, then while the case above may be clear, this is not necessarily true for a=b AND c. BTW, Pascal is a langauge which has such type rules, but it got the precedence between = and AND wrong (and that was not corrected in Modula-2 or Oberon).

Followups set to comp.arch

- anton -- M. Anton Ertl Some things have to be seen to be believed


List | Previous | Next

Where should the type information be 140

Alt Folklore Computers Newsgroups

Where should the type information be 138