On 04/05/2013 02:50 AM, Tobias Pankrath wrote:
On Friday, 5 April 2013 at 06:20:05 UTC, Chad Joan wrote:

I still can't escape the feeling that this is a hack to work around
limitations of the language or lack of knowledge.

The only hack around a language limitation I see in this thread is the
use of prefixes to distinguish between different enums.

Your comparison between enum and modules is misplaced. It's better to
compare enums with structs and classes.

---
module A;

struct Foo {
enum name = "foo";
}
--
module B;
import A;

void main() { writeln(name); } // don't think that should work
---

And it shouldn't work for enums, too. Imports should only pull top level
names into a scope.



I am unconvinced:

Enums are analogous to a list of constants, not to a struct or a class. Structs and classes have instances. Enums do not have instances.

Whenever I see
---
enum Foo
{
        X,
        Y
}
---
I think of it as being similar to
---
const X = 0;
const Y = 1;
---
with the primary differences of type safety and manifest-constant-ness (the enum acts more like a preprocessor define in C and creates immediate values rather than link-time symbols).

Reply via email to