Christopher Wright wrote:
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.

Relax. It's a condition known as literalitis. :o)

Literals only have you write [ a, b, c ] instead of toArray(a, b, c). I wouldn't see it a big deal one way or another, but the issue is that the former is a one-time decision that pretty much can't be changed, whereas toArray can benefit of the hindsight of experience.


Andrei

Reply via email to