Re: [sv-ec] Class static member initialization

From: Steven Sharp <sharp_at_.....>
Date: Thu Oct 30 2008 - 14:18:29 PDT
Continuing this digression, here is an example where the requirement for
a constant expression gets in the way.  Consider a case where I want to
assign a unique id to each class object when it is allocated, and I don't
want that id to get changed.  I would like to write

  class c;
    static int num_allocated;
    const int my_id = num_allocated++;
  endclass
  
Instead, I have to write

  class c;
    static int num_allocated;
    const int my_id;
    function new;
      my_id = num_allocated++;
    endfunction
  endclass
  
The initializers were intended to avoid this extra verbosity, so why
require it here?

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Oct 30 14:29:14 2008

This archive was generated by hypermail 2.1.8 : Thu Oct 30 2008 - 14:29:43 PDT