Jonathan, Your proposal is very sensible. On fact, I had discussed some time ago enhancing SV to allow the second form you propose (D1'new). The obvious benefit of such an enhancement is that it does not require the declaration of a temporary simply to construct the object. since this is not a major show-stopper (only a convenience feature), I don't think we should consider this enhancement for the upcoming standard. Arturo -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Jonathan Bromley Sent: Friday, August 03, 2007 8:51 AM To: sv-ec@eda-stds.org Subject: [sv-ec] Explicitly typed constructors? hi sv-ec, In some recent work I've frequently encountered the situation that I have a variable of base class type, but wish to be able to construct objects of various derived types and use the common base variable to reference them. To construct the derived objects, I need a derived-type variable (don't I?): class Base; .... virtual function void v(); ... .... endclass : Base class D1 extends Base; .... endclass class D2 extends Base; .... endclass .... Base b; D1 d1; D2 d2; .... d1 = new; b = d1; b.v(); .... d2 = new; b = d2; b.v(); It would be very nice if I could force new() to create an object of a derived-class type even though the result of new() is then assigned immediately to a base-class variable: something like b = D1::new(); b.v(); b = D2::new(); b.v(); Or, maybe, b = D1'new(); Either way, the idea is to mirror Java's b = new D1(); Has this already been dismissed for some reason? I'm no OOP guru, but I can't see any killer reason why it should be unreasonable. Thanks -- 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 The contents of 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. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri Aug 3 12:14:45 2007
This archive was generated by hypermail 2.1.8 : Fri Aug 03 2007 - 12:15:08 PDT