DMD 1.035 and 2.019 releases
Walter Bright
newshound1 at digitalmars.com
Wed Sep 3 00:57:40 PDT 2008
Max Samukha wrote:
> On Tue, 02 Sep 2008 22:42:06 -0700, Walter Bright
> <newshound1 at digitalmars.com> wrote:
>
>> Struct constructors!
>>
>> http://www.digitalmars.com/d/1.0/changelog.html
>> http://ftp.digitalmars.com/dmd.1.035.zip
>>
>> http://www.digitalmars.com/d/2.0/changelog.html
>> http://ftp.digitalmars.com/dmd.2.019.zip
>
> Thanks! Two questions about the struct constructors:
>
> 1. Why is there the limitation that the constructor list may not be
> empty? One problem with that rule is incorrect handling of a single
> parameter with a default value:
>
> struct S
> {
> this(int x = 1)
> {
> writefln("Ctor");
> }
> }
>
> S s = S();
>
> The constructor is not called. Is such a parameter list considered
> empty or non-empty?
Empty.
> 2. How do constructiors affect static opCalls?
>
> struct S
> {
> this(int x)
> {
> }
>
> static void opCall(int x, int y)
> {
> }
> }
>
> S s;
> s(1, 2);
>
> Error: constructor Test.main.S.this (int x) does not match parameter
> types (int,int)
>
>
> dmd seems to ignore static opCalls completely, if there is a
> constructor. Is it intended behavior?
Yes, that's exactly how it works.
More information about the Digitalmars-d-announce
mailing list