RE: [sv-ec] FW: A question about super.new

From: Arturo Salz <Arturo.Salz_at_.....>
Date: Thu Jan 18 2007 - 13:33:46 PST
Almost, but just to make sure, I should point out that you can also
specify *default arguments* using the inheritance syntax:

	class foo;
	    function new( int b ) ... endfunction
	endclass

	class bar extends foo( 3 );

Which is equivalent to:

	class bar extends foo;
	    function new(); super.new( 3 ); endfunction
	endclass

Hence, if neither of these mechanisms is used to extend class foo, the
compiler will insert a super.new - with no arguments - that will result
in a type-checking error.

Alternatively, class foo could provide a default argument, which I
believe is what you meant, as in:

	class foo;
	    function new( int b = 3 ) ... endfunction
	endclass

And, in this case, super.new() is valid.

	Arturo

-----Original Message-----
From: Rich, Dave [mailto:Dave_Rich@mentor.com] 
Sent: Thursday, January 18, 2007 11:47 AM
To: Arturo Salz; sv-ec@eda.org; prabhakar.s.ayyagari@intel.com
Subject: RE: [sv-ec] FW: A question about super.new


I think the corollary to this rule is that if the super class
constructor has non-defaulted arguments, the subclass must have an
explicit constructor with an explicit call to super.new as its first
executable statement.

When the compiler inserts an implict call to super.new, it does so
without any arguments.

Dave



> -----Original Message-----
> From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org]
On
> Behalf Of Arturo Salz
> Sent: Wednesday, January 17, 2007 6:35 PM
> To: sv-ec@server.eda.org; prabhakar.s.ayyagari@intel.com
> Subject: RE: [sv-ec] FW: A question about super.new
> 
> Satya,
> 
> That's not correct. If used, super.new must be the first executable
> statement in the constructor, regardless on whether the constructor of
> the superclass accepts any arguments or not. If the constructor of the
> superclass takes no arguments or the class extension specifies the
> arguments it accepts then the entire statement can be omitted as the
> compiler will automatically insert a call to super.new at the start of
> the constructor.
> 
> 	Arturo
> 
> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
> Mehdi Mohtashemi
> Sent: Wednesday, January 17, 2007 6:21 PM
> To: sv-ec@eda.org
> Subject: [sv-ec] FW: A question about super.new
> 
> FWD a question to the sv-ec alias.
> 
> -----Original Message-----
> From: Ayyagari, Prabhakar S [mailto:prabhakar.s.ayyagari@intel.com]
> Sent: Wednesday, January 17, 2007 5:28 PM
> To: owner-sv-ec@eda.org
> Subject: A question about super.new
> 
> Hi,
> 
> Can I infer the following from sections 7.14 and 7.16:
> super.new() need not be the first executable statement in the
> constructor if the superclass does not have any arguments (or) is
> super.new() always required to be the first executable statement with
or
> without arguments.
> 
> Section 7.14:
> When using the super within new, super.new shall be the first
statement
> **executed** in the constructor.
> 
> Section 7.16:
> A more general approach is to use the super keyword, to call the
> superclass constructor:
> 
> function new();
>     super.new(5);
> endfunction
> 
> To use this approach, super.new(...) ** must be the first executable
> statement ** in the function new.
> 
> 
> Thanks,
> Satya P Ayyagari
> 
> --
> 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.
> 
> 
> 
> --
> 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 Thu Jan 18 14:11:29 2007

This archive was generated by hypermail 2.1.8 : Thu Jan 18 2007 - 14:11:39 PST