class instance construction

Steven Schveighoffer schveiguy at yahoo.com
Thu Nov 11 09:10:42 PST 2010


On Thu, 11 Nov 2010 11:57:40 -0500, Daniel Gibson <metalcaedes at gmail.com>  
wrote:

> spir schrieb:
>> Still, an other case when "new" annoys me is method chaining, because  
>> it makes syntax heavier and less readable:
>> 	c = (new C(p)).do(x);
>> versus:
>> 	c = C(p).do(x);
>> Or, maybe, the parser could be clever enough to correctly decode:
>> 	c = new C(p).do(x);
>>
>
> Is this really a common case?
> Constructing an object, just to call *one* method on it and then throw  
> it away?

If the do method returns this, you aren't throwing it away.

-Steve


More information about the Digitalmars-d mailing list