On Thu, 11 Nov 2010 12:10:42 -0500, Steven Schveighoffer <[email protected]> wrote:

On Thu, 11 Nov 2010 11:57:40 -0500, Daniel Gibson <[email protected]> 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.

A realistic example (from dcollections):

auto ll = (new LinkedList(someOtherCollection)).sort();

http://www.dsource.org/projects/dcollections/browser/branches/d2/dcollections/LinkList.d#L1054

That being said, I'm really ambivalent on whether this needs to be included. It's not that terrible that you have to parenthesize properly.

-Steve

Reply via email to