Do I need A::A_enum::low?
Would not A::low be sufficient?
As Dave Rich said, enumerals are defined in the scopes containing the
definitions of the type. For this example, those scopes would be A::
and B::, no?
On Fri, May 21, 2010 at 6:07 PM, Arturo Salz <Arturo.Salz@synopsys.com> wrote:
> The "right" thing would be to use the scope resolution operator, as in:
>
> A a;
> B b;
> initial begin
> a = new; b=new;
> a.a_e = A::A_enum::low;
> b.b_e = B::B_enum::low;
> end
>
> Arturo
>
> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Rich, Dave
> Sent: Friday, May 21, 2010 2:12 PM
> To: James Keithan; sv-ec@eda.org
> Subject: RE: [sv-ec] scope of enumerated type names
>
> Hi James,
>
> Enum names are declared in the same scope as the enumeration type, so
> yes you can reuse names in different scopes. That also means you can't
> reuse names in the same scope. For example
>
> class A;
> typedef enum {low, high} A_enum;
> typedef enum {low, hi} B_enum; // illegal - low is already declared
> int low; // also illegal - the identifier 'low' is already declared
> in this scope
> endclass
>
> The LRM does have a problem that was recently mentioned
>
> class A;
> typedef enum {low, high} A_enum;
> A_enum a_e;
> endclass
>
> class B;
> typedef enum {high, low} B_enum;
> B_enum b_e;
> endclass
>
> A a;
> B b;
> initial begin
> a = new; b=new;
> a.a_e = low;
> b.b_e = low;
> end
>
> Some tools will "do the right thing" but there are no rules in the LRM
> that make this legal; low is not a visible identifier.
>
> Dave
>
>
>> -----Original Message-----
>> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
> James
>> Keithan
>> Sent: Friday, May 21, 2010 1:56 PM
>> To: sv-ec@eda.org
>> Subject: [sv-ec] scope of enumerated type names
>>
>>
>> Language Folks,
>> What are the scoping rules for names in enumerated types?
>>
>> Can you use the same name in different scopes?
>>
>> class A;
>> typedef enum {low, high} A_enum;
>> endclass
>>
>> class B;
>> typedef enum {low, high} B_enum;
>> endclass
>>
>>
>> Legal or not?
>>
>> James
>>
>>
>>
>> --
>> 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.
>
>
>
> --
> 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 Fri May 21 16:24:30 2010
This archive was generated by hypermail 2.1.8 : Fri May 21 2010 - 16:24:36 PDT