[dmd-beta] dmd 2.064 beta take 2
Rory McGuire
rjmcguire at gmail.com
Wed May 15 23:48:40 PDT 2013
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.
On Thu, May 16, 2013 at 8:16 AM, d coder <dlang.coder at gmail.com> wrote:
>
> On Thu, May 16, 2013 at 11:33 AM, Lars Tandle Kyllingstad <
> lars at kyllingen.net> wrote:
>
>> Are you proposing that this be allowed:
>>
>> struct S
>> {
>> immutable int c = 123;
>> this(int i) { c = i; }
>> }
>>
>> and that the compiler should report an error on the following?
>>
>> struct S
>> {
>> immutable int c = 123;
>> // No constructor
>> }
>>
>
> As I understand, he is proposing that either the first code snippet be
> allowed OR the second one should be an error.
>
> Regards
> - Puneet
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20130516/93abbf31/attachment.html>
More information about the dmd-beta
mailing list