Array literals

bearophile bearophileHUGS at lycos.com
Fri Oct 17 05:18:26 PDT 2008


Nick Sabalausky:
> I like T[static] a lot. Static might be a highly overloaded word, but the 
> idea of a "static array" is already one of the firmly established overloads. 
> You want a static array? Say "static". Nice :)

+1.
I think it's acceptable. So the code equivalent to the original one becomes (plus the immutable statement):

import std.stdio: writefln;
void main() {
    char[static][static] a = ["Hello", "what"];
    writefln(a[2].length); // 5
}

Most of the times you don't want that so you use:

auto a = ["Hello", "what"];

Now we can wait for Walter to express his opinion on this improvement of the language.

Bye,
bearophile



More information about the Digitalmars-d mailing list