Regards Surya
The issue here is user-defined new vs. copy constructor. SomeClass sc1, sc2; sc2 = new sc1; // This is copy constructor: sc2 becomes a shallow copy of sc1. sc2 = new (17); // This is a call to a user-defined function new() sc2 = new (sc1); // This is also a call to a user-defined function new() - that takes SomeClass as an argument! The difference between the copy constructor and the user-defined new call is the parentheses: no parentheses are used for the copy constructor. An expression inside parentheses is always interpreted as a call to a user-defined constructor. I agree that this ought to be clarified. On Thu, Mar 26, 2009 at 9:19 AM, Surya Pratik Saha <spsaha@cal.interrasystems.com> wrote:Hi, Class new rule is defined in the LRM as: class_new18 ::= new [ ( list_of_arguments ) | expression ] And here is the definition of sub-rule: list_of_arguments ::= [ expression ] { , [ expression ] } { , . identifier ( [ expression ] ) } | . identifier ( [ expression ] ) { , . identifier ( [ expression ] ) } expression ::= primary [...] primary ::= primary_literal [...] | ( mintypmax_expression ) mintypmax_expression ::= expression | expression : expression : expression So a new expression like 'new (1)' can be reached both by "new '(' list_of_arguments')'" rule and "new expression" rule. Which is conflicting. And also semantically 'expression' after 'new' just pointing to a class object. So I think a subset of expression is valid here. Is there any mantis regarding that? -- Regards Surya -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This email was Anti Virus checked by Astaro Security Gateway. http://www.astaro.com
This archive was generated by hypermail 2.1.8 : Thu Mar 26 2009 - 21:35:29 PDT