New feature proposal: "initialization scope"
Jacob Carlborg
doob at me.com
Thu May 16 01:02:04 PDT 2013
On 2013-05-16 09:53, TommiT wrote:
> I'd like to make it easier to initialize function local immutable/const
> data. Here's the type of problem I'd like to alleviate:
>
> const string[100] int__str;
> const int[string] str__int;
>
> for (int i = 0; i < 100; ++i)
> {
> auto str = to!string(i);
> int__str[i] = str; // ERROR: Can't modify const
> str__int[str] = i; // ERROR: Can't modify const
> }
>
> In short, I want to initialize two different const variables at once (in
> the same loop or other block).
Use a module constructor:
static this () { }
http://dlang.org/module.html#staticorder
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list