Re: [sv-bc] Forward reference of baseclass

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Thu Feb 14 2008 - 07:11:19 PST
Alok Kumar Sinha wrote:
> Thanks Gord,
> 
> Actually my querry came in the context of the mail conversation between 
> you, Surya and shweta with subject line
> "Forward typedef of parameterized class" . In this context, I want to 
> extend my querry that is it legal to
> have parameter assignment list with a forward reference of class?
> For e.g.
> 
> typedef C;

This is a special case and one that I don't like very much
since it further confuses the type/parameterized class issues.

In this case "C" is a forward declaration to a parameterized
class.

> C #(3) x = new; // <---- Is it legal with #()
> class D extends C #(1); // <--- Is it legal with #()
> endclass
> class C #(parameter p = 2) ;
> endclass
> 
> Is it legal ?

This is legal although the discussions that lead to the
agreement that it should be legal were relatively recent so
I don't know how widely this would be supported yet.
And yes, C#() would also be legal.  I don't recall whether
there was agreement as to whether use of just "C" was
valid or whether C#() was required for the default
specialization.  I don't have time right now to try to
dig up that discussion.

The above does NOT contradict my previous post in which I
said that
     class C#(parameter type T = int) extends T;
     endclass
was NOT legal -- T here can only bind to an actual type
and not a parameterized class.

One thing that might help here is if you think about a
parameterized class as a type factory and not a type
itself.  A type parameter can only bind to an actual
type and not a type factory (a parameterized class).
A forward typedef is the special case in which it is
permitted to define the forward name of either an actual
type or a type factory (a parameterized class).


> According to you "a non-type access has no special restrictions and 
> should be legal, assuming of course that
> the target of such a reference is a static property or method."

This quote is entirely out of context in this discussion.  The
quote was in the context of issues related to when "::" is valid
with a forward type.  The "non-type" refers to what was begin
accessed and has nothing to do with the prefix.

Gord.


> 
> Regards
> Alok
> 
> Gordon Vreugdenhil wrote:
> 
>> I've been gone for a week and in looking through my
>> backlog of email, I haven't seen a response to this,
>> so I'll take a shot at this one.
>>
>> I consider this example to be illegal.  "T" in
>> the "extends T#(3)"  is the **type** parameter
>> to C.  There is no way to have a pass an unspecialized
>> parameterized class reference as a type parameter --
>> any type reference to a parameterized class denotes a
>> specialized type.  So "T#(3)" here is illegal since
>> "T" can't denote a parameterized class.
>>
>> You could have:
>>
>>    class C#(parameter type T = int) extends T;
>>    endclass
>>
>> and then your example would be valid.
>>
>> Given:
>>     C #( D #(2)) x = new;
>> the type parameter "T" of C binds to the type
>> specialized from D#(2) so the effective type
>> could be thought of as having:
>>      class C extends D#(2);
>>         typedef D#(2) T;
>>         ....
>>      endclass
>> This of course isn't exactly what happens, but it
>> is a reasonable approximation of what results for
>> this particular specialization of C.  Other
>> specializations of C with different type bindings
>> for "T" would produce other class derivations.
>>
>> Gord.
>>
>>
>> Alok Kumar Sinha wrote:
>>
>>> Hi
>>>
>>> Consider the scenario :
>>> module top;
>>> class C #(parameter type T = int) extends T #(3);
>>> endclass
>>> class D #(parameter p = 1);
>>> endclass
>>>
>>> C #( D #(2)) x = new;
>>>
>>> endmodule
>>>
>>> If this case is syntactically and semantically correct then what 
>>> parameter value should be propagated to the class 'D'.
>>> Whether it should be  '2'  from  'D  #(2)' or '3' from 'T #(3)' ?
>>>
>>> Regards
>>> Alok
>>>
>>>
>>>
>>
> 
> 
> 

-- 
--------------------------------------------------------------------
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 Thu Feb 14 07:12:07 2008

This archive was generated by hypermail 2.1.8 : Thu Feb 14 2008 - 07:13:09 PST