digitalmars.D - Body of Programming
- Robert V. Abrams III (36/36) May 07 2004 I have a suggestion that will drastically improve the look of D. Instead...
- Ivan 'Killer927' Cebola (4/4) May 06 2004 I'm sorry to say but that idea would be actually bad, just see why VB is
- Unknown W. Brackets (20/30) May 07 2004 You're just excusing spaghetti code.... that's the problem I'm seeing......
- Unknown W. Brackets (7/8) May 07 2004 Not my mistake, but this should be:
- Andy Friesen (12/29) May 07 2004 The only place where I would think this necessary is when using
- clayasaurus (23/37) May 07 2004 I'm not a fan of that, however i see what you mean. This problem can eas...
- Brad Anderson (9/53) May 07 2004 I guess what you can take from these responses, in a word, is : "indent...
- Mark T (4/8) May 08 2004 Artistic Style would probably do this already (I haven't tried yet) and ...
I have a suggestion that will drastically improve the look of D. Instead of using brackets to begin and terminate functions and definitions, use some sort of an end statement for to designate the termination of functions, control structures, and class definitions. C++'s failure to do this has resulted in the confusion of many a programmer as to where a function\class definition\control structure would begin and end. For example: for (int i = 0; i <= 20; i++) { // perform actions int value = 0; for (int k = 0; k = 4; k++) { doSomething(value) switch (value) { //cases } } } Would confuse someone when looking for where the loops and switches begin and end. Plus if someone were to practice good programming style, they would have to // end for or // end switch at every end bracket, which is nerve wrecking. What I propose is to have D do this: for (int i = 0; i <= 20; i++) : // perform actions int value = 0; for (int k = 0; k = 4; k++) : doSomething(value) switch (value) : //cases :end switch :end for :end for Notice the difference? I clearly delineated the beginning and the ending of each control structure and function. This also brings the language closer to human language, making it more understandable. I base my findings directly on the languages of Perl and PHP, as they have adopted the same conventions that not only encourage good programming practices, but also is easier to follow. Robert Vincent Abrams III
May 07 2004
I'm sorry to say but that idea would be actually bad, just see why VB is hated by many: it's way too verbose, this would increase the verbosity of D in a large amount. Ivan "Killer927" Cebola
May 06 2004
Robert V. Abrams III wrote:For example: for (int i = 0; i <= 20; i++) { // perform actions int value = 0; for (int k = 0; k = 4; k++) { doSomething(value) switch (value) { //cases } } }You're just excusing spaghetti code.... that's the problem I'm seeing... I would write it as: for (int i = 0; i <= 20; i++) { int value = 0; // Perform actions. for (int k = 0; k = 4; k++) { doSomething(value); switch (value) { // Cases here. } } } Looks totally clear to me when written up properly. Conversely, using endwhile etc. (things that are DEPRECATED in PHP...) only makes the code ugly and makes it more excusable to use spaghetti code... -[Unknown]
May 07 2004
Unknown W. Brackets wrote:for (int k = 0; k = 4; k++)Not my mistake, but this should be: for (int k = 0; k <= 4; k++) Or: for (int k = 0; k != 4; k++) See what you find when you indent properly? -[Unknown]
May 07 2004
Robert V. Abrams III wrote:Would confuse someone when looking for where the loops and switches begin and end. Plus if someone were to practice good programming style, they would have to // end for or // end switch at every end bracket, which is nerve wrecking.The only place where I would think this necessary is when using syntactic contortions like the venerable Duff's device, which nobody in their right mind should be using anyway. Maybe it would be sensible if the body of the loop doesn't fit onscreen, but you have other, far more pressing problems to worry about if that's the case.What I propose is to have D do this: for (int i = 0; i <= 20; i++) : // perform actions int value = 0; for (int k = 0; k = 4; k++) : doSomething(value) switch (value) : //cases :end switch :end for :end for Notice the difference?Nope. It's still a big opaque mess. Even worse, it's more cluttery even if formatted correctly. It's excessive, verbose syntax for something that's completely self-evident to any sane human being. (ie anyone who indents their code properly) -- andy
May 07 2004
I'm not a fan of that, however i see what you mean. This problem can easily be solved if someone take time to comment their loops like switch() { for () { if () { } // end if } // end for } // end switch() being able to use the tab helps a lot. i kind of see what you mean, but if there was built in language support for this is should use better syntax like switch() { for () { if () { } end if } end for } end switch() or people should be able to comment that part in themselves.What I propose is to have D do this: for (int i = 0; i <= 20; i++) : // perform actions int value = 0; for (int k = 0; k = 4; k++) : doSomething(value) switch (value) : //cases :end switch :end for :end for Notice the difference?
May 07 2004
I guess what you can take from these responses, in a word, is : "indent" Indent your code clearly, and things begin to make sense. Try Jalopy for Java code: http://jalopy.sourceforge.net/ Better yet, re-write this utility in D. It will clearly delineate your code, no matter if you receive it like the big opaque block you proposed. Send it through your Dalopy utility (hosted at dsource.org, of course) and you'd see the code clear as day. BA Robert V. Abrams III wrote:I have a suggestion that will drastically improve the look of D. Instead of using brackets to begin and terminate functions and definitions, use some sort of an end statement for to designate the termination of functions, control structures, and class definitions. C++'s failure to do this has resulted in the confusion of many a programmer as to where a function\class definition\control structure would begin and end. For example: for (int i = 0; i <= 20; i++) { // perform actions int value = 0; for (int k = 0; k = 4; k++) { doSomething(value) switch (value) { //cases } } } Would confuse someone when looking for where the loops and switches begin and end. Plus if someone were to practice good programming style, they would have to // end for or // end switch at every end bracket, which is nerve wrecking. What I propose is to have D do this: for (int i = 0; i <= 20; i++) : // perform actions int value = 0; for (int k = 0; k = 4; k++) : doSomething(value) switch (value) : //cases :end switch :end for :end for Notice the difference? I clearly delineated the beginning and the ending of each control structure and function. This also brings the language closer to human language, making it more understandable. I base my findings directly on the languages of Perl and PHP, as they have adopted the same conventions that not only encourage good programming practices, but also is easier to follow. Robert Vincent Abrams III
May 07 2004
In article <c7hnlh$2n15$3 digitaldaemon.com>, Brad Anderson says...I guess what you can take from these responses, in a word, is : "indent" Indent your code clearly, and things begin to make sense. Try Jalopy for Java code: http://jalopy.sourceforge.net/ Better yet, re-write this utility in DArtistic Style would probably do this already (I haven't tried yet) and would probably much easier to add D capability. http://astyle.sourceforge.net/
May 08 2004