digitalmars.D.learn - new X().bar(); is a syntax error?
- Ary Manzana (14/14) Sep 20 2007 Compiling:
- BCS (3/20) Sep 20 2007 I think it's not parsing how you want it, try this:
- Ary Manzana (3/26) Sep 20 2007 But I can do it without parenthesis in other languages... I'll try to
- Robert Fraser (2/29) Sep 20 2007
Compiling: --- class X { void bar() { } } void foo() { new X().bar(); } --- gives me: main.d(7): found '.' when expecting ';' following 'statement' Is this a bug or is it the intended behaviour? I can do this in Java,
Sep 20 2007
Reply to Ary,Compiling: --- class X { void bar() { } } void foo() { new X().bar(); } --- gives me: main.d(7): found '.' when expecting ';' following 'statement' Is this a bug or is it the intended behaviour? I can do this in Java,I think it's not parsing how you want it, try this: (new X()).bar();
Sep 20 2007
BCS escribió:Reply to Ary,But I can do it without parenthesis in other languages... I'll try to fix this in Descent's parser and submit a bug report.Compiling: --- class X { void bar() { } } void foo() { new X().bar(); } --- gives me: main.d(7): found '.' when expecting ';' following 'statement' Is this a bug or is it the intended behaviour? I can do this in Java,I think it's not parsing how you want it, try this: (new X()).bar();
Sep 20 2007
I think it might create a parsing ambiguity. Since you can refer to inner clases by prefixing them with the name of the object or type, there's no way to tell during the syntactic pass whether it's a qualified type name or a call parentheses at the end of the new expression, so once it hits a closing parenthesis, the parser knows that's the end of the new expression. Ary Manzana Wrote:BCS escribió:Reply to Ary,But I can do it without parenthesis in other languages... I'll try to fix this in Descent's parser and submit a bug report.Compiling: --- class X { void bar() { } } void foo() { new X().bar(); } --- gives me: main.d(7): found '.' when expecting ';' following 'statement' Is this a bug or is it the intended behaviour? I can do this in Java,I think it's not parsing how you want it, try this: (new X()).bar();
Sep 20 2007