3 ms·
Me too. I suppose "+ 1" is ambiguous enough that the compiler is interpreting it differently based on context, but it just feels wrong.
by Splines 16y ago
Me too. I suppose "+ 1" is ambiguous enough that the compiler is interpreting it differently based on context, but it just feels wrong.
- drblast 16y agoI was taught in CS101, as I think just about everyone is, that the & operator means "the address of." So parsing &x + 1 into English becomes: "The address of x plus one." Except that, more explicitly, we should say: "The address of x plus one times the size of the type of x." What you should say is so far removed from the C code appears to say (add 1 to something) that confusion is inevitable. That the second term should depend on the implicit type information from the first term, especially when the "address" operator has precedence over the + operator, seems backward to me. To me an address is just a number, it carries no type information. Translate to s-expressions: (+ (address-of x) 1) Does it make sense that the 1 would change value based on the result of "address-of"? Not to me. I think it's bad design. Now, if it were taught differently: (+ (typed-reference-to x) 1) Then it makes more sense.