Re: for puzzlement

new topic     » goto parent     » topic index » view thread      » older message » newer message
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu