Precedence vs order, redux

Once more I’m revisting the myth that order of evaluation has any relationship to operator precedence in C#. Here’s a version of this myth that I hear every now and then. Suppose you’ve got a field arr that is an array of ints, and some local variables index and value: int index = 0;int value =…

10

Precedence vs Associativity vs Order

Raymond has written about this, I have written about Raymond writing about it, but I still frequently get questions from people who are unclear on the difference between precedence, associativity and evaluation order. I suspect that this confusion arises from the difference between how most people are trained to evaluate arithmetical expressions versus how compilers generate…

13

C++ and the Pit Of Despair

Raymond has an interesting post today about two subtle aspects of C#: how order of evaluation in an expression is specified as strictly left-to-right, and how the rules regarding local shadowing ensure that an identifier has exactly one meaning in a local scope. He makes an educated guess that the reason for these sorts of rules is to…

15

Bad Recursion Revisited

We have internal email lists for questions about programming languages. Here’s one that came across recently that I thought illustrated a good point about language design. An interview candidate gave the following awful implementation of the factorial function. (Recall that factorial is notated “n!”, and is defined as the product of all the integers from…

22