main declaration

Steven Schveighoffer schveiguy at
Fri Mar 19 05:04:09 PDT 2010

On Fri, 19 Mar 2010 06:23:36 -0400, bearophile <bearophileHUGS at>  

> So in D1 (string[] args) is the same as (char[][] args), but in D2 they  
> are a little different things. Even if D2 accepts both forms, I think  
> that modifying the contents of args is not a good practice, so in D2 I  
> suggest to use (string[] args), that has immutable chars.
> In practice in D2 you can even use main(immutable string[] args), that I  
> think is the best form :-)

You are allowed to modify the args, they are guaranteed not to be in ROM.   
The true signature, if there existed such a thing, should be  
unique(char[])[] args.  Because D arrays are safe, you are in no danger of  
corrupting memory, unlike C.

However, the docs should be updated to add the string[] variant, I agree  
with that.


More information about the Digitalmars-d-learn mailing list