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?
That way you can supply the default in the constructors arguments, and everyone can see exactly what is going on. In the cases where the variable's value cannot be overridden you HAVE to use static with a default initializer.