Re: [sv-ec] class property lifetimes

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Tue Jan 20 2009 - 14:32:13 PST
Steven Sharp wrote:
> I don't think it is really appropriate to have class properties declared
> as automatic.  They are either static, or not static.  If they are not
> static, they are allocated dynamically in the class object, not in a stack
> frame like automatics.  But I suppose you could think of them as being
> allocated "automatically" by new, instead of by entering their scope.
> At any rate, I don't think there would be any problem with allowing an
> explicit "automatic" to mean nonstatic.  Does C++ allow auto to be used
> on a class property?
> 
> On the second question, I don't think there is any distinction for a class
> property between a class qualifier of static and a lifetime of static.

I agree, with the proviso that you think about "static" in the
general context of generate-like constructs.  In particular
"static" doesn't necessarily mean quite the same as "unique"
in the presence of parameterized classes.  A "static" member
of a parameterized class is created for each unique type
specialization of the class.

So lifetime "static" in the sense of "is created during elaboration"
is an appropriate model but one must be careful to not equate a
class static with a non-auto declaration in the enclosing context.

Quick example:
    package pkg;
       int x;
       class C #(p = 1);
          static int y;
       endclass
       typedef C#()  C1;
       typedef C#(2) C2;
    endpackage

There is only one "x" (pkg::x) but there are two "y"s -- C1::y and
C2::y.

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 Tue Jan 20 14:33:19 2009

This archive was generated by hypermail 2.1.8 : Tue Jan 20 2009 - 14:33:41 PST