This comment is a month late, so I have included the original email at the end for reference. An alternative syntax would be to use a cast to the desired class type: b = C'(new()); A cast is equivalent to an assignment to an intermediate variable of the cast type. So this would be equivalent to an assignment to an intermediate variable of type C. This would indicate that new() should create an object of type C, since it is assigning to a variable of type C. It may seem odd to have an assignment that casts to a type other than that of the LHS. The cast is the opposite of the actual conversion that is being done implicitly, from the derived class to the base class. You could do that explicitly if it seemed clearer: b = B'(C'(new())); >X-eda.org-MailScanner-Watermark: 1221205409.14454@H2k1J8JaWJvPqJ9LlcxJiA >X-Authentication-Warning: server.eda.org: majordom set sender to owner-sv-ec@eda.org using -f >X-eda.org-MailScanner-Watermark: 1221205367.5615@8X9B9lMwFlqKcS4vslDfaQ >From: "Daniel Mlynek" <daniel.mlynek@aldec.com> >To: <sv-ec@eda-stds.org> >Subject: [sv-ec] class construction syntax - new feature proposal >Date: Fri, 5 Sep 2008 09:42:44 +0200 >MIME-Version: 1.0 >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 >Thread-Index: AckPKvviIvjumlokQL6tdxj9ARI53w== >X-OriginalArrivalTime: 05 Sep 2008 07:42:44.0842 (UTC) FILETIME=[FC0B6CA0:01C90F2A] >X-eda.org-MailScanner: Found to be clean, Found to be clean >X-Spam-Status: No, No >X-eda.org-MailScanner-Information: Please contact the ISP for more information >X-MailScanner-ID: m857hPq5003715 >X-eda.org-MailScanner-From: owner-sv-ec@server.eda.org >X-pstn-neptune: 8/1/0.12/25 >X-pstn-levels: (S:60.82089/99.90000 CV:99.9999 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) >X-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c >X-pstn-addresses: from <daniel.mlynek@aldec.com> [145/6] >X-Received: By mx-sanjose2.Cadence.COM as m857jO52026332 at Fri Sep 5 00:45:24 2008 > >There is one annoying thing in object contruction syntax in SV - there is no >neat and nice way to create an object of user choosen type and assign it to >handle of different (compatybile type) - consider: > >class B; >endclass >class C extends B; >endclass > >C c; >B b; > >initial begin > c=new; > b=c; //I have to write 2 lines of code to create and assign object of >child type to handle of base type >//my proposal is to accept syntax: new <class_type_identifier> - which >always creates an object of pointed type and returns handle to it > b = new C; >end > >I haven't found mantis on it and I cannot see any obsticles to add it to >LRM. I've think that this is very usefull - so please consider adding such >feature. > > >DANiel > >-- >This message has been scanned for viruses and >dangerous content by MailScanner, and is >believed to be clean. > Steven Sharp sharp@cadence.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri Oct 3 09:51:58 2008
This archive was generated by hypermail 2.1.8 : Fri Oct 03 2008 - 09:52:48 PDT