March 27, 2013 Re: Bug in using string mixins inside of a struct? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kenji hara | On 03/27/2013 12:33 PM, kenji hara wrote: > 2013/3/27 Timon Gehr <timon.gehr@gmx.ch <mailto:timon.gehr@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. |
Copyright © 1999-2021 by the D Language Foundation