Simplifying for () Statements in the C++ compiler:

By: Scott A. Wyzlic

My proposal is to make some modifications to the C++ for () structure. This change may sound quite simple, but I believe that its usefulness is evident in its simplistic nature. Most C++ programmers write a tremendous amount of loops within each of their given programs, and the tediousness of rewriting for(int i = 0; i < some.int; i++) is just too painful to be useful. I believe that the same effect of for (@, 100) where the @ replaces int i, int j; and int k; automatically as an int, followed by the iteration for the loop would be of great assistance to many programmers. The iteration and declaration are automatic, @ is automatically set to 0, and each time through the loop incremented to whatever is specified. This is only an addition to the compiler, and traditional for loops can still be written. I don’t believe there are any negative effects of this change, and the benefits that will arise can be seen in this simple example:

Text Box: Nested for () statements could be written in this form:
		For (@, 100){ 
			For (@, somestring.length()){
				If (@2 == @1)
/*tokenize @’s which do you mean? The first @1 in the structure or the second @2….etc. or the 1000’th. @1000 */
For statements can be rewritten using one symbol followed by an int or string.length() for(@, 100) == for(int i = 0; i < 100; i++). If a string is being used for length for (@, somestring.length()) ==  for(int i = 0; i <some_sting.length(); i++) and both can be used with some very simple additions to the C++ compiler, and the compiler would keep them in order, the same as it does now. This is a simple change that I believe would gain universal acceptance and would be a result of a very minor and simple change to the C++ compiler.

This change, its usefulness, and acceptance are evident in the perl programming language. And I believe that it would be an acceptable addition to the C++ programming language. It could also be used in other languages that make the same claim as C/C++ in their definitions of the for() structure. Programs already in existence would not be affected by this change, because this is an addition to the compiler and would not cause any program to crash, but additions to existing programs would be able to incorporate its use (backwards compatibility). I believe the functionality of this addition to the C++ programming language will, however minutely, increase compiling time and help increase the functionality of for ()loops.