Comments below. -Tom
-----Original Message-----
From: Gordon Vreugdenhil [mailto:gordonv@model.com]
Sent: Monday, August 16, 2010 2:40 PM
To: Alsop, Thomas R
Cc: sv-ec@eda.org; Tipp, Brandon P
Subject: Re: [sv-ec] Multiple Inheritance Proposal
Tom and Brandon,
Thanks for the initial directions.
Just to check my understanding of what you posted, given:
pure virtual
class A#(p = 1);
pure virtual function int f();
endclass
pure virtual
class B#(p = 1);
pure virtual function int g();
endclass
It would be impossible for any class to implement
both a specialization of A and a specialization of
B since both classes have a symbol (the parameter)
named "p".
Is that a correct implication of the intent?
[Alsop, Thomas R] It all boils down to where 'p' is scoped, right? In your example, 'p' is scoped _within_ both pure virtual classes, right? 'p' is not seen outside the class. But when we extend a class, the scope of a parameter is still in the at the class scope when it's extended. I would assume that 'implement' of a class should do the same thing. That would mean in the case above that 'p' would collide if they are both 'implement'd.
Essentially it becomes the user's responsibility to make
sure that all names are distinct between any set of
classes which participate in an "implements" clauses.
[Alsop, Thomas R] Yes.
As a second question, if a class "implements" A#(5),
what is the compatibility rule for symbols? For
methods, I assume that the rules are essentially
the "overriding" rules, but what about other symbols?
For example, given my defn of "A" above, which of the
following would be legal (clearly some are not correct
in terms of intent, but what is legal and what is the
rule constraining legality):
1)
class myA implements A#(7);
function int f(); return 1; endfunction
endclass
[Alsop, Thomas R] This would be fine. Parameter value is 7.
2)
class myA implements A#(7);
localparam p = 5;
function int f(); return 1; endfunction
endclass
[Alsop, Thomas R] This feels like a collision of parameters and should be an error.
3)
class myA implements A#(7);
static int p = 5;
function int f(); return 1; endfunction
endclass
[Alsop, Thomas R] I would say a collision of tokens and should be an error. Otherwise how does the implementation know which 'p' is being referred to?
4)
class myA implements A#(7);
typedef int p;
function int f(); return 1; endfunction
endclass
[Alsop, Thomas R] Again, a token collision.
5)
class myA extends B#(7) implements A#(5);
function int f(); return 1; endfunction
function int g(); return 1; endfunction
endclass
[Alsop, Thomas R] Feels like a collision, but I can hear users saying something like A and B should be separate scopes. IMHO, I think this is another collision.
6)
class myA extends B#(7) implements A#(7);
function int f(); return 1; endfunction
function int f(); return 1; endfunction
endclass
[Alsop, Thomas R] Bottom line, and I may be wrong, but I don't see how we can make this work when you have all the token collisions you have created above. Unless there is a way to infer which 'p' is referenced, but even then it feels like bad coding practices.
I have some additional intent and expectation questions
but would like to understand the visibility assumptions
and constraints that you expect first.
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 Mon Aug 16 16:02:11 2010
This archive was generated by hypermail 2.1.8 : Mon Aug 16 2010 - 16:02:19 PDT