New feature proposal: "initialization scope"

TommiT tommitissari at hotmail.com
Thu May 16 01:14:10 PDT 2013


On Thursday, 16 May 2013 at 08:02:05 UTC, Jacob Carlborg wrote:
> Use a module constructor:
>
> static this () { }
>
> http://dlang.org/module.html#staticorder

On Thursday, 16 May 2013 at 08:01:44 UTC, Timothee Cour wrote:
> this works:
>
>
> import std.stdio;
> import std.conv;
> const string[100] int__str;
> const int[string] str__int;
>
> static this(){
>     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
>     }
> }

But I'm talking about function local data. The initialization of 
that data might depend on the arguments passed to the function.


More information about the Digitalmars-d mailing list