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.Received on Fri May 21 14:12:25 2010
This archive was generated by hypermail 2.1.8 : Fri May 21 2010 - 14:12:31 PDT