const main args?

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 15 06:47:53 PDT 2011


On Fri, 12 Aug 2011 17:51:50 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> > int main(in string[] args);
>>
>> What would be the purpose of this?
>
> Why do you use "in" in function arguments? To make sure you will not  
> modify the given array. I think it's not good practice to change the  
> length of the input strings of the main or replace it with another  
> dynamic array at runtime.

int main(string[] _args)
{
    const args = _args;  // not modifiable copy
}

It's a very easy problem to solve, and it's not really worth changing the  
compiler for IMO.

In other words, it's one of those "features" that's so trivial that it's  
not worth implementing.  D cannot always be perfect, and I'd rather we  
spend more time on the meaty parts of the language.

-Steve


More information about the Digitalmars-d-learn mailing list