Array literals' default type

Christopher Wright dhasenan at gmail.com
Fri Oct 9 15:24:07 PDT 2009


Don wrote:
> I don't understand why runtime-determined array literals even exist.
> They're not literals!!!
> They cause no end of trouble. IMHO we'd be *much* better off without them.

You don't see the use. I do. I would go on a murderous rampage if that 
feature were removed from the language.

For example, one thing I recently wrote involved creating a process with 
a large number of arguments. The invocation looked like:
exec("description", [procName, arg1, arg2] ~ generatedArgs ~ [arg3, 
arg4] ~ moreGeneratedArgs);

There were about ten or fifteen lines like that.

You'd suggest I rewrite that how?
char[][] args;
args ~= procName;
args ~= arg1;
args ~= arg2;
args ~= generatedArgs;
args ~= arg3;

Just fucking shoot me. Or better yet, whoever removed array literals 
with non-constant elements from the language.



More information about the Digitalmars-d mailing list