Declare and Define Before Use? [rant]

kdevel kdevel at vogtner.de
Wed Apr 4 19:51:27 UTC 2018


On Wednesday, 4 April 2018 at 19:19:30 UTC, Ali wrote:
> On Wednesday, 4 April 2018 at 18:57:27 UTC, kdevel wrote:
> [...]
> I think the rules should have been the same everywhere
> and if there was an exception to be made, it could be made for 
> the main function
> since the main function is special anyway

The main function of a program corresponds to the final paragraph 
of a novel. I never understood why programmers place this 
function which possibly depends on all other functions in the 
translation unit at the beginning.

BTW: You can't write

    void main ()
    {
       x.writeln;
       int x;
    }
    import std.stdio;

There is no reason why the declaration of x should not be 
postponed.


More information about the Digitalmars-d-learn mailing list