On Friday, 24 May 2013 at 14:04:33 UTC, Dicebot wrote:
On Friday, 24 May 2013 at 13:58:32 UTC, Steven Schveighoffer
wrote:
Being able to dictate the .init data is very powerful and
useful. You can't remove that feature.
Sure, I completely agree, thus the idea adding of CTFE-able
constructor which will become the T.init for structs.
But the point I'm making is that the syntax IS consistent. It
just never worked before, because of the implicit 'static'
No it is not. It never worked before because it was simply
broken. Now it works properly from the point of spec, but it is
inconsistent from the point of language design:
int x = 5; // can you tell without looking at scope if it
really initializes x or just defines .init for aggregate?
Initializer syntax does not really make sense for non-static
aggregate members at all, mutable or not.
They define a default value for the field. The constructor can
override it. It is expected that a constructor is able to
construct an object.