DMD 0.177 release

Lars Ivar Igesund larsivar at igesund.net
Sun Dec 10 01:49:46 PST 2006


Walter Bright wrote:

> Burton Radons wrote:
>> Here's the difference:
>> 
>>     struct S
>>     {
>>         this (int x)
>>         {
>>             w = calculate_something (x);
>>         }
>> 
>>         this (int x, int y)
>>         {
>>             this (x);
>>             z = calculate (y);
>>         }
>>     }
> 
> struct S
> {
>      static S opCall(int x)
>      {
> S result;
> result.w = calculate_something(x);
> return result;
>      }
> 
>      static S opCall(int x, int y)
>      {
> auto result = S(x);
> result.z = calculate(y);
> return result;
>      }
> }
> 
> It's 3 more lines of code. The two styles almost completely overlap, and
> since the latter is already in use, adding ctors just seems redundant.

Struct can have opCall, which is why they were used as a workaround for
ctors. This was almost ok, but creating language support (through statement
rewriting) for a workaround sounds a very bad thing to add prior to 1.0.
This is certainly controversial enough, to think over for more than 2
weeks. I personally agree with those who want struct ctors.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi



More information about the Digitalmars-d-announce mailing list