C72: A port of the earliest C compiler to x86 (2021)
github.com
github.com
Personally I always thought that made more sense than the (now) standard way because when you read it aloud it reads like the operation you’re performing:
N equals N plus five
N =+ 5
I still find myself occasionally writing those operators that way around even after decades of using C and similar languages. n =- 5
n = -5
n=-5 n =- 5 // n equals n - 5
n = -5 // n equals -5
n=-5 //Illegal
This can be done, it just requires getting the lexer right.n =* p;
Is p a pointer or an integer? Maybe you want to do pointer math, it's a very C thing to do.
x - (--y)
or (x--) - yx---y is (x--)-y, which is semantically valid.
x-----y is ((x--)--)-y - but it's a semantic error, as x-- is not an lvalue.
Oh wow, I've read bits and pieces about early iterations of C but I didn't realise for loops weren't there from the start.
for(int i = 0; i < 10; i++);
Is just int i = 0;
while(i < 10)
i++; {
int i = 0;
while(i < 10)
i++;
} int i = 0;
while (i < 10) {
defer i++;
// ...
continue;
// ...
}https://news.ycombinator.com/item?id=28166125
https://sentido-labs.com/en/library/cedro/202106171400/#defe...
[1] I might be sloppy with the terminology here, but you catch my drift.
You can avoid it, but it'll involve one of repetition, a wrapper function, or "formalizing" the cleanup so that it's your only cleanup call. Depending on the situation those are all going to be way more verbose.
Some advanced use cases include jumping between "case" labels, or jumping into the middle of a loop. Most of the time that's bad practice, but in the cases that benefit from them it's much better than the alternatives.
You can know that, but you feel it when you work on various codebases with different people / switch teams.
So, yes. Nobody is right or wrong in these topics. Moreover, there are situations where one is clearly better than the other.
If you need to (formally) verify your code, depending on the method, maybe early returns are to be avoided.
Yes, this is ultimately about the push for structured programming, which involves creating a pattern language of loops with "clean" semantics. Grouping the loop advancing statement with the other parts of a general loop construct helps wrt. recognition of known looping patterns.