# enum namespacing

**URL:** <https://community.zeek.org/t/enum-namespacing/1835>\
**Category:** Development\
**Tags:** development\
**Created:** [March 17, 2011, 1:35pm UTC](https://community.zeek.org/t/enum-namespacing/1835 "2011-03-17T13:35:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seth\_Hall3](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Seth\_Hall3](https://community.zeek.org/u/Seth_Hall3)\
**Post date:** [March 17, 2011, 1:35pm UTC](https://community.zeek.org/t/enum-namespacing/1835/1 "2011-03-17T13:35:40Z")

</div>

Does it makes sense that an enum would be in the name space it's declared within even if it's extending an enum type from another namespace?

My example:

module Software;

export {  
&nbsp;&nbsp;type Type: enum { UNKNOWN };  
}

module HTTP;

redef enum Software::Type += { WEB\_SERVER };

event bro\_init()  
&nbsp;&nbsp;{  
&nbsp;&nbsp;# I would expect this to be true, but it seems that WEB\_SERVER was placed into the HTTP namespace and this doesn't work.  
&nbsp;&nbsp;print Software::WEB\_SERVER;  
&nbsp;&nbsp;}

&nbsp;&nbsp;.Seth

---

<div class="post-metadata">

**Author:** ![Vern](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/vern/32/630_2.png) [@Vern](https://community.zeek.org/u/Vern)\
**Post date:** [March 22, 2011, 3:12am UTC](https://community.zeek.org/t/enum-namespacing/1835/2 "2011-03-22T03:12:39Z")

</div>

> Does it makes sense that an enum would be in the name space it's declared  
> within even if it's extending an enum type from another namespace?

Huh. I have a nagging sense that there's no correct answer to this one  
... However, the behavior you show matches what seems to me more likely  
to accord with Principle Of Least Surprise.

&nbsp;&nbsp;&nbsp;&nbsp;Vern

---

<div class="post-metadata">

**Author:** ![Seth\_Hall3](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Seth\_Hall3](https://community.zeek.org/u/Seth_Hall3)\
**Post date:** [March 22, 2011, 3:54pm UTC](https://community.zeek.org/t/enum-namespacing/1835/3 "2011-03-22T15:54:50Z")

</div>

Fair enough. I'll have to think about how this some more then.

&nbsp;&nbsp;.Seth

---

<div class="post-metadata">

**Author:** ![Gregor\_Maier](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@Gregor\_Maier](https://community.zeek.org/u/Gregor_Maier)\
**Post date:** [March 25, 2011, 1:59am UTC](https://community.zeek.org/t/enum-namespacing/1835/4 "2011-03-25T01:59:39Z")

</div>

Note that currently the NOTICE framework is the part the mostly makes  
use of extended Enums and there it makes sense for the extended elements  
to live in the enclosing name-space (in your example HTTP).

I guess the current rule is: if an identifier does not have a Foo::  
module specifier, it's placed in the current module. So,

module HTTP;  
redef enum Software::Type += { Software::UNKNOWN }; # UNKNOWN in  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Software namespace  
redef enum Software::Type += { UNKNOWN }; # unknown in HTTP namespace

just my 2ct  
Gregor

---

<div class="post-metadata">

**Author:** ![Seth\_Hall3](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Seth\_Hall3](https://community.zeek.org/u/Seth_Hall3)\
**Post date:** [March 25, 2011, 2:12am UTC](https://community.zeek.org/t/enum-namespacing/1835/5 "2011-03-25T02:12:03Z")

</div>

This is what would seem to make the most sense to me, but doesn't seem to be true currently.

&nbsp;&nbsp;.Seth

---

<div class="post-metadata">

**Author:** ![Gregor\_Maier](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@Gregor\_Maier](https://community.zeek.org/u/Gregor_Maier)\
**Post date:** [March 25, 2011, 4:06am UTC](https://community.zeek.org/t/enum-namespacing/1835/6 "2011-03-25T04:06:34Z")

</div>

> > module HTTP;  
> > redef enum Software::Type += { Software::UNKNOWN }; # UNKNOWN in  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Software namespace  
> > redef enum Software::Type += { UNKNOWN }; # unknown in HTTP namespace
> 
> This is what would seem to make the most sense to me, but doesn't seem to be true currently.

Huh. I thought that's what it was doing. At least that's what I thought  
your mail said. I must have misunderstood it.  
Can you briefly explain the current behavior?

thx  
gregor

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:39pm UTC](https://community.zeek.org/t/enum-namespacing/1835/7 "2022-05-06T15:39:29Z")

</div>


