(prefix ops) => ( statement ) =>(postfix ops)
Which made code like *a++ = *b--;
Change the pointers after the copy as opposed to having them change before the copy.It is interesting that this has become compiler defined.
51–60 of 67 posts
(prefix ops) => ( statement ) =>(postfix ops)
Which made code like *a++ = *b--;
Change the pointers after the copy as opposed to having them change before the copy.It is interesting that this has become compiler defined.
int a[] = {10,20,30};
int r = 1 * a[i++] + 2 * a[i++] + 3 * a[i++];
with int a[] = {1,2,3};
int r = 1 * a[i++] + 10 * a[i++] + 100 * a[i++];
Then if your program outputs r = 111, it's obvious that it's doing a[0] + 10*a[0] + 100*a[0]
and if it outputs 321, it's obvious that it's doing a[0] + 10*a[1] + 100*a[2]
No disassembly required.Yo always do multiple lines, with comments on each one.
It sounds ridiculous, but this simple thing made some kind of bugs impossible: those that you have in front of you but you can't see in a million years. The atomic operation in code is the line, you can't debug a complex line(1).
It is painful forcing people to do that, people use to hate being told what to do, but at the same time they love the outcome so much. In the end everybody loves it.
1.With assembly you are debugging an instance of your code. You are not debugging what will be created with any compiler, any os or architecture.
One of the things we train any newcomer to our company is to never do what this man does:a complex single line with expected behavior based on your (arbitrary) conventions. Yo always do multiple lines, with comments on each one. It sounds ridiculous, but this simple thing made some kind of bugs impossible: those that you have in front of you but you can't see in a million years. The atomic operation in code is the li…
I mean suppose I split the first part of the statement like this:
int r = a[ i ];
++i;
These lines are self-explanatory. It's pretty hard to argue they need a comment? Especially when used in a function that already should have a name/comment explaining what it does?Interesting, my first guess would have been '60' since the old C89 / K&R C had the behavior (prefix ops) => ( statement ) =>(postfix ops) Which made code like *a++ = *b--; Change the pointers after the copy as opposed to having them change before the copy. It is interesting that this has become compiler defined.
Lesson I took away: The ++ operator should be deprecated except when it's the only operation on that line.
Interesting, my first guess would have been '60' since the old C89 / K&R C had the behavior (prefix ops) => ( statement ) =>(postfix ops) Which made code like *a++ = *b--; Change the pointers after the copy as opposed to having them change before the copy. It is interesting that this has become compiler defined.
It hasn't. You're not modifying a single variable twice within a single sequence point in that example.