3 ms·
Even with that explanation I am not convinced of the soundness of that notation. For example, if you think you have a particular row that is causing you some pr
by S4M 11y ago
Even with that explanation I am not convinced of the soundness of that notation. For example, if you think you have a particular row that is causing you some problem and want to add a print statement for the row number, your code becomes, if you are too quick and forget to add braces:
for(y=0; y<ymax; y++)
printf("y=%i\n",y);
for(x=0; x<xmax; x++)
{
//...
}
And it will not work anymore as intended.
Granted it's a small mistake and it will not take more than 5 minutes to fix, but it still add a small load to your already busy mind.
- deleted 11y ago[deleted]
- GFK_of_xmaspast 11y agoTotally agreed, but in this case if the author had declared the variable in the for-loop: for(int y=0; y < ymax; y++) ... and didn't shadow y from an enclosing scope, that would have given the compiler a chance to catch that error.
- jimrandomh 11y agoThis doesn't seem like a realistic mistake to me. The printf is just at the wrong indent level; this is the same mistake as: for(i=0; i<imax; i++) printf("i=%i\n",i) { //... } Which also compiles and which is wrong in the same way. I don't recall ever having made or having seen this.
- S4M 11y agoWell, not really, because in the example you just gave, you would put the printf right between the braces as it should be. In the case originally discussed, you have no braces so you would have to add them, and that can be forgotten.