Bug in using string mixins inside of a struct?
Timon Gehr
timon.gehr at gmx.ch
Wed Mar 27 04:49:22 PDT 2013
On 03/27/2013 12:33 PM, kenji hara wrote:
> 2013/3/27 Timon Gehr <timon.gehr at gmx.ch <mailto:timon.gehr at gmx.ch>>
>
> 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.
>
Obviously.
> ...
> So, variables in template declaration will always make "static' variables.
>
> ...
Non-static variables should just be disallowed, as they are in the
'const' case. Implicitly adding static does not reduce confusion.
Furthermore, it would be ok to template function-local variables, a nice
future extension that is blocked by this design.
More information about the Digitalmars-d
mailing list