www.digitalmars.com         C & C++   DMDScript  

D - forward references

reply "Pavel Minayev" <evilone omen.ru> writes:
Their implementation in D seems unclear to me.
On one hand, they are allowed - at least in alpha:

    int function(int n);    // works!

On other hand, they don't serve any practical meaning -
D doesn't need them anyhow, and there is no way
to define a body once the prototype was declared:

    int function(int n) { }    // symbol conflict

So what are they for?
Dec 15 2001
parent "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:9vgete$138v$1 digitaldaemon.com...
 Their implementation in D seems unclear to me.
 On one hand, they are allowed - at least in alpha:

     int function(int n);    // works!

 On other hand, they don't serve any practical meaning -
 D doesn't need them anyhow, and there is no way
 to define a body once the prototype was declared:

     int function(int n) { }    // symbol conflict

 So what are they for?
They're for if you really do want to create a library with a hidden implementation of the functions. The way to do it would be make a copy of the module, and delete the function bodies.
Dec 16 2001