Re: [sv-ec] is this illegal code?

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Tue Jan 08 2008 - 14:58:17 PST
Francoise Martinolle wrote:
> 
> module top;
>   class base #(parameter q = 1);
>   endclass
>  
>   class derived #( int j = q) extends base#();
>   endclass
>  
> endmodule
>  
>  
>  
> Should we resolve q to base::q, or should be q unknown because the 
> extends has not been seen yet?

I would consider q to be unknown.  Consider the following:

    class derived #( int j = q) extends base#(j);
    endclass

That would be pretty weird if you had to consider
"q" as being part of "derived".

However,

    class derived #( int j = 2) extends base#(j);
    endclass

should certainly be legal.


My basic view is that there are several steps
here -- the parameterization, the creation of the base
type, and finally the creation of the derived type.
The super type here -- base#(j) -- is a type construction
that can depend on the parameterization of the derived
type since the derived type can specify the parameters
of its base.  However the base type can't possible
exist until the parameterization is determined so
you can't have the base type define the parameters.

This may be easier to think about if you consider
parameterization as a top-down activity and type construction
as a bottom-up activity.

> This should be legal though:
>  
>   class derived #( int j = base#()::q) extends base#();
>   endclass

Sure -- that does things in a completely different manner
though.  The default parameter is defined by a separately
specialized type.  That type might happen to be the same
as the base type (or not).

Gord


-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jan 8 14:58:33 2008

This archive was generated by hypermail 2.1.8 : Tue Jan 08 2008 - 14:58:54 PST