2013/3/27 Timon Gehr <[email protected]>

> Because of a questionable patch (written by Kenji Hara, I think) some time
> ago, the following works:
>
> struct S{
>     template T(int x){
>         auto s = x; // implicitly static
>     }
> }
>
> I consider this bad language design.


In above case, 's' cannot make a field in S.
Because such a feature would make impossible to determine the size of S.

void main() {
    S s;
    assert(s.T!0.s == 0);  // If T!0.s is a field of s,
    assert(s.T!1.s == 1);  // also T!1.s is a field...
    pragma(msg, S.sizeof == ??);  // ???
}

So, variables in template declaration will always make "static' variables.

Kenji Hara

Reply via email to