Workaround for foreward declaration ?
Peter Sommerfeld
noreply at rubrica.at
Sun Mar 3 06:39:38 PST 2013
According to http://dlang.org/ctod.html foreward declarations
are not needed because functions can be defined in any order.
But that seems not to be true for inner functions. A somewhat
artificial example:
-----------------------------
import std.stdio;
void main(string[] args){
int count;
// void foo() -- unlike in C in D not possible
void bar(){
++count;
writeln("bar");
foo(); // ERROR: undefined identifier foo
}
void foo(){
writeln("foo");
if(count){
writeln("foo again");
return;
}
bar();
}
foo();
}
---------------------------------------
Is there a workaround for such a situation or do I have
to put everything outside the enclosing function.
Peter
More information about the Digitalmars-d-learn
mailing list