[sv-ec] Initialisation of static data members

From: Jonathan Bromley <jonathan.bromley_at_.....>
Date: Tue Aug 08 2006 - 02:30:51 PDT
Given a base class

  class Base;
    static local int N = 0;
    static function int nextN(); nextN=N; N++; endfunction
  endclass

is it legitimate to call its static member function in the
initializer of a static data member of a derived class?

  class Derived extends Base;
    static local int NN = super.nextN(); // or Base::nextN() ??
    function int getNN(); return NN; endfunction
  endclass

My specific motivation here is that if Derived is a parameterized
class, then I get a different value of NN for each specialization.

The example I show above has a common-sense interpretation (static
parts of Derived are built after the static parts of Base, so the
function call is reasonable) but I can easily see why implementations
might wish to outlaw such a construct.  The LRM doesn't appear to
place any restriction on the initializer for a static data member,
although it *does* restrict the initialiser on a "const" to be
a constant expression, and it *does* hint that static data 
members may often be const.

Thanks
-- 
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

This e-mail and any  attachments are  confidential and Doulos Ltd. reserves 
all rights of privilege in  respect thereof. It is intended for the use of 
the addressee only. If you are not the intended recipient please delete it 
from  your  system, any  use, disclosure, or copying  of this  document is 
unauthorised. The contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
Received on Tue Aug 8 02:30:57 2006

This archive was generated by hypermail 2.1.8 : Tue Aug 08 2006 - 02:31:28 PDT