Re: [sv-ec] class property lifetimes

From: Surya Pratik Saha <spsaha_at_.....>
Date: Tue Jan 20 2009 - 20:37:09 PST
Hi,
I have similar type of confusion on class method.
As per BNF, we can declare a method in both the ways:

class C;
    task static t; // method lifetime
       ...
    endtask
endclass

class C;
    static task t; // class item qualifier
       ...
    endtask
endclass

Also its other combinations allowed. Do both mean same? I did not see 
anything in the LRM about this.

Regards
Surya



-------- Original Message  --------
Subject: Re:[sv-ec] class property lifetimes
From: Gordon Vreugdenhil <gordonv@Model.com>
To: Steven Sharp <sharp@cadence.com>
Cc: sv-ec@eda.org, shalom.bresticker@intel.com, yulik.feldman@intel.com
Date: Wednesday, January 21, 2009 4:02:13 AM
>
>
> 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.
>




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jan 20 20:38:43 2009

This archive was generated by hypermail 2.1.8 : Tue Jan 20 2009 - 20:39:28 PST