# Enum tag collision

**URL:** https://discourse.julialang.org/t/enum-tag-collision/13047
**Category:** General Usage
**Tags:** question, enum
**Created:** [August 8, 2018, 6:17pm UTC](https://discourse.julialang.org/t/enum-tag-collision/13047 "2018-08-08T18:17:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Antigonus](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Antigonus](https://discourse.julialang.org/u/Antigonus)
#### Post date: [August 8, 2018, 6:17pm UTC](https://discourse.julialang.org/t/enum-tag-collision/13047/1 "2018-08-08T18:17:18Z")

</div>

```julia
julia> @enum( Fruit, apple, orange, banana)
julia> @enum( Color, red, orange, blue)
ERROR: invalid redefinition of constant orange

```

I have many enums in a program at the same scope, and the program might even be autogenerated. What is the proper/simple way to do this so that each appears in its own namespace? Say, Fruit::orange, Color::orange ?

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [August 8, 2018, 6:27pm UTC](https://discourse.julialang.org/t/enum-tag-collision/13047/2 "2018-08-08T18:27:50Z")

</div>

You could certainly do

```julia
module Fruit
    @enum(FruitType, apple, orange banana) 
end 
module Colors
    @enum(ColorType, red, orange, blue)
end 

```

Though I don’t think it was ever intended that you have hundreds of modules at a time, so I’m not sure if there are performance limitations involved.

On a more general note I’m not sure cluttering any namespace with a large number of procedurally generated names is a good idea.

---

<div class="post-metadata">

### Author: ![Antigonus](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Antigonus](https://discourse.julialang.org/u/Antigonus)
#### Post date: [August 8, 2018, 8:24pm UTC](https://discourse.julialang.org/t/enum-tag-collision/13047/3 "2018-08-08T20:24:13Z")

</div>

I tried to stick all that into a macro for my\_enum, and got the error

```julia
ERROR: syntax: "module" expression not at top level

```

so it looks like that approach will be limited to top level enum definitions … but it works for the current problem at hand. Thanks … though would like to have a general solution … or are enums top level only beasts?
