"Frank Benoit" <keinfarb...@googlemail.com> wrote in message news:gtqf6c$8m...@digitalmars.com... > In Java one can write: > > new MyClass().run(); > > in D this does not compile, parenthesis are needed. > > (new MyClass()).run(); > > But why is the D language designed like that?
I'm torn on this. On one hand, I'm uncomfortable with having an operator that requires whitespaces bind tighter than an operator that isn't typically used with whitespace. To me, "new MyClass().run();" just *looks* like run() returns a type and you're trying to instantiate *that* type (with a default constructor). But on the other hand, I can certainly see the practiclity of the Java version and I've frequently had reason to use "(new MyClass()).run();" in my own code.