On 16/05/2013 08:48, Rory McGuire wrote:
struct S
{
immutable int c = 123; // I agree with Walter, what if this is
far away from the constructor
this(int i) { c = i; }
}
struct S
{
immutable int c = 123; // This should be static, compiler issues
error
// No constructor
}
would it be possible to disallow a default initializer for const /
immutable member variables and instead allow a single assignment from
the constructor?
You can't disallow default initialisers in general, e.g. in the first
case above, because then the programmer no longer has the power to
decide what S.init should look like. I don't think that is acceptable.
Don may be right that it is necessary to require 'static' in the second
case, though, to avoid silent breakage.
Lars
_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta