const main args?

Timon Gehr timon.gehr at gmx.ch
Mon Aug 15 14:37:59 PDT 2011


On 08/15/2011 03:47 PM, Steven Schveighoffer wrote:
> 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

This is a place where D trivially could be perfect ;). I agree that this 
issue has a very low priority. But it should be fixed eventually.



More information about the Digitalmars-d-learn mailing list