[dmd-beta] dmd 2.064 beta take 2
Lars Tandle Kyllingstad
lars at kyllingen.net
Thu May 16 00:11:07 PDT 2013
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
More information about the dmd-beta
mailing list