www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - new operator chaining (D vs Java)

reply =?UTF-8?B?Ikx1w61z?= Marques" <luis luismarques.eu> writes:
I've used D to some extent since around 2004, but I don't recall 
noticing this before (although I wouldn't trust 9 year old 
memories!):

     D: (new Class()).foo();

     Java: new Class().foo();

Is there any particular (purposeful) reason why D cannot directly 
chain calls after new? (a quick Google search did not help).
Aug 19 2013
parent reply "Andrej Mitrovic" <andrej.mitrovich gmail.com> writes:
On Tuesday, 20 August 2013 at 02:11:41 UTC, Luís Marques wrote:
 Is there any particular (purposeful) reason why D cannot 
 directly chain calls after new? (a quick Google search did not 
 help).
This syntax will work in the next release (2.064).
Aug 19 2013
parent reply =?UTF-8?B?Ikx1w61z?= Marques" <luis luismarques.eu> writes:
On Tuesday, 20 August 2013 at 02:20:27 UTC, Andrej Mitrovic wrote:
 This syntax will work in the next release (2.064).
Wow, now that is a coincidence! :-) (how it took me so long to notice it, just before it was going to be added to the language)
Aug 19 2013
parent reply "deadalnix" <deadalnix gmail.com> writes:
On Tuesday, 20 August 2013 at 02:25:35 UTC, Luís Marques wrote:
 On Tuesday, 20 August 2013 at 02:20:27 UTC, Andrej Mitrovic 
 wrote:
 This syntax will work in the next release (2.064).
Wow, now that is a coincidence! :-) (how it took me so long to notice it, just before it was going to be added to the language)
That isn't coincidence ;) BTW, it is supposed to work by spec for ages.
Aug 20 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-08-20 11:02, deadalnix wrote:
 On Tuesday, 20 August 2013 at 02:25:35 UTC, Luís Marques wrote:
 On Tuesday, 20 August 2013 at 02:20:27 UTC, Andrej Mitrovic wrote:
 This syntax will work in the next release (2.064).
Wow, now that is a coincidence! :-) (how it took me so long to notice it, just before it was going to be added to the language)
That isn't coincidence ;) BTW, it is supposed to work by spec for ages.
I have been adding parentheses in DWT for ages :(. At least it's good that it's finally changed. -- /Jacob Carlborg
Aug 20 2013