Re: for puzzlement
- Posted by ghaberek (admin) Jan 10, 2019
- 1328 views
euphoric said...
Somebody catch me up: Why would you pre-declare your loop variables?
In many languages, you have to declare the type of the for variable, and some may just require that be done before the for loop. Euphoria can infer the type from values given to the loop.
Fun fact: in the early days of C you had to do this. You also had to declare your parameter types between the function declaration and its body. Early C is weird.
void myfunc( foo, bar ) int foo; char *bar; { int i; for (i = 0; i < foo; i++) { printf( "i = %d\n", i ); } printf( "bar = '%s'\n", bar ); }
-Greg