RE: [sv-ec] Derived classes and package imports

From: Arturo Salz <Arturo.Salz_at_.....>
Date: Tue Feb 13 2007 - 13:36:57 PST
This was the gist of the "package chaining" discussion. My position at
that time was that such imports should indeed be available. The
situation presented by Jonathan is precisely the type of issue that
guided my thinking.

	Arturo

-----Original Message-----
From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
Jonathan Bromley
Sent: Tuesday, February 13, 2007 7:13 AM
To: sv-ec@eda.org
Subject: [sv-ec] Derived classes and package imports

This is probably a really stupid question, but it has
me a little confused.

Suppose I have a base class declared in a package:

  package P;
    class B;
      logic L;
    endclass : B
  endpackage : P

and then I want an extension of B but I don't want
to modify the original package's source code.  
So I write a new package:

  package Q;
    import P::*;  // to get definition of B
    class C extends B;
      logic M;
    endclass : C
  endpackage : Q

So far, so good; but now I try to use this:

  program PP;
    import Q::*;  // gets C, but no chained import of P
    C c = new;  // OK
    initial begin
      $display(c.M);  // definitely OK
      $display(c.L);  // is this OK?  I guess so.
    end
    initial begin
      B b;  // can I do this?  I guess not.
      b = c;  // typical upcast
    end
  endprogram : PP

In other words: If I import a package containing a definition
of a class derived from a class it imports from another package,
how much of the base class definition can I see?

Usual apologies in advance if this is something obvious I
should have known already.
-- 
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223                   Email:
jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573                           Web:
http://www.doulos.com

The contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.

-- 
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 Tue Feb 13 13:37:19 2007

This archive was generated by hypermail 2.1.8 : Tue Feb 13 2007 - 13:37:28 PST