[Gord] > During construction, you cannot safely call an > overridden method since the derived class state would not have > been initialized yet. As with C++ (ISO C++ 1998, Sec 12.7), > SV should clarify that during construction you effectively > change your vtbl as construction progresses so that you only > get "the most derived" override vis-a-vis the type of "new" > that you are currently executing. This is rather self-evidently sensible, but current tools are not unanimous about it; currently I count one in Gord's favour, two in Chris's. At present I recommend to people that they should completely avoid calling virtual methods from a constructor. While we're thinking about constructors, can I raise something I've been meaning to ask for ages? The constructor is, in many respects, a static method. If new() could be treated truly as a static method, then we could get this rather convenient idiom: class C;... class D extends C; ... ... C c; c = D::new(); Is there any fundamental problem with this that I've missed? -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 Email: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com This message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Jun 25 10:42:17 2008
This archive was generated by hypermail 2.1.8 : Wed Jun 25 2008 - 10:42:54 PDT