DMD 1.035 and 2.019 releases

Max Samukha samukha at voliacable.com.removethis
Wed Sep 3 01:34:04 PDT 2008


On Wed, 03 Sep 2008 00:57:40 -0700, Walter Bright
<newshound1 at digitalmars.com> wrote:

>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.

Should it be a compile time error? The above is semantically
equivalent to

struct S
{
	this()
	{
		this(1);	
	}

	this(int x)
	{
	}
}

which is not allowed.

Incidentally, calling other constructors from a constructor doesn't
work. Is it a bug? 

>
>
>
>> 2. How do constructiors affect static opCalls?
>> 
>> struct S
>> {
>> 	this(int x)
>> 	{
>> 	}
>> 
>> 	static void opCall(int x, int y)
>> 	{
>> 	}
>> }
>> 
>> S s;
>> s(1, 2); 

Correction: should be "S(1, 2);". "S s;" is not needed. 
>> 
>> 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