Re: [sv-ec] question about name resolution in classes

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Sun Mar 26 2006 - 16:57:54 PST
Arturo Salz wrote:
> I have to agree with Gord on this issue. Enforcing pure classes might be
> too restricting for many users --- but they are probably a very good
> methodology.
> 
> Getting back to the previous discussion, I believe the current consensus
> is towards restricting the language to allow only "lexically static" or
> "locally static" classes. 


No, that is not at all what Francoise and I were proposing.  I would
be very opposed to such a proposal to restrict derivation.


The context of the "lexically static" discussion was to define
when inherited members were visible directly and when they
would need to be prefixed ("this." "super." or "base::")
in order to be disambiguated from a visible name outside the class.

There was no suggestion to restrict the actual derivation,
only to clarify rules that impact names that might need
to otherwise be imported from packages or bind to non-member
names.

Your example is clear under the rules that I suggested:
all of the participating classes qualify as "lexically
static" and thus Derived::foo definitely refers to Base::i.

This is the kind of misunderstanding that I think Francoise
was concerned about in my suggestion of the term "lexically static".
"Lexically" is somewhat misleading; the intent of whatever
term we use is that it expresses when base properties cannot
be determined prior to elaboration.

Gord.




 > I don't care what we call them as long as we
> are clear what we mean and are able to describe it in unambiguous terms
> in the LRM. If we decide to go that route then I'd like to take a stab
> at what those restrictions might be:
> 
> In order for a class to be a legal base class (from which other classes
> are derived), the class (and all its super classes) must be lexically
> static at the point of extension. This means that the base classes must
> be either (a) declared within the scope of the extending class, or (b)
> declared in a package. Any other use would be illegal.
> Does "lexical locality" affect declaration before use binding? Consider
> the example below:
> 
> program test;
>   typedef class Base;
> 
>   int i = 10;
> 
>   class Derived extends Base;
>      task foo;
>         $display(i);
>     endtask
>   endclass
>   
>   class Base;
>     int i;
>   endclass
>   
>   Derived d = new;
> 
>   initial begin
>     d.i = 20;
>     d.foo();
>   end
>   
>  endprogram
> 
> Should this print 10 or 20?
> I believe the answer depends on what "lexical locality" means.
> 
> 	Arturo
> 
-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
Received on Sun Mar 26 16:57:59 2006

This archive was generated by hypermail 2.1.8 : Sun Mar 26 2006 - 16:58:12 PST