4 ms·
But it's not simply a matter of creativity. Apart from contentious instances pertaining to the complete omission of indentation (if (sdfg) { a; b; }), there are
by 4bpp 15y ago
But it's not simply a matter of creativity. Apart from contentious instances pertaining to the complete omission of indentation (if (sdfg) { a; b; }), there are also occasional cases where I'd argue that semantically, you have a block, but syntactically, you don't; for instance, I've always very much favoured the approach when writing OpenGL code to indent everything between a glBegin and glEnd to separate the vertex data from the surrounding code and make it immediately obvious how objects in the scene are grouped. I think several indentation-based languages would ignore the initial indent increase here and consider the indent decrease before the glEnd to be the end of the block containing the group of statements...
- sanxiyn 15y agoYes, that is useful. That's why Python has with statements, for example. C++ RAII or Java try-with-resources can be used similarly. http://www.python.org/dev/peps/pep-0343/ http://www.python.org/dev/peps/pep-0343/