User defined attributes use

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Mon Sep 16 12:50:22 PDT 2013


On Monday, 16 September 2013 at 19:28:22 UTC, Andrei Alexandrescu 
wrote:
> On 9/16/13 11:56 AM, Namespace wrote:
>> And I agree absolute, to disable default CTor's by struct's 
>> was a huge
>> mistake. But D is full of those. ;)
>
> They are not disabled. It seems many people are having trouble 
> with getting default constructors to evaluate code, so I assume 
> you mean that. One possibility (or first step) would be to 
> relax the language to allow CTFE-executable code in default 
> constructors.

Yes, we REALLY need this. I know that we can init struct fields 
via user-defined value, but for many cases is not enough. And in 
that days I  remembered C++.

Buy the way, what does it mean "They are not disabled"?

struct Foo
{
	int i = 5; //works
}

struct Bar
{
	int i;
	
	this()
	{
		i = 5;
	}
}

DMD:
src/app.d(10): Error: constructor app.Bar.this default 
constructor for structs only allowed with @disable and no body


More information about the Digitalmars-d-learn mailing list