3 ms·
I can't understand how forcing coding convention can result in "being restricted by a totalitarian scheme". We are writing in a formal language instead of Engli
by sanxiyn 15y ago
I can't understand how forcing coding convention can result in "being restricted by a totalitarian scheme". We are writing in a formal language instead of English. Style is the last place you want creativity. Use you creativity to express algorithms, not brace styles.
- 4bpp 15y agoBut 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/