Is enum static?

Jonathan M Davis jmdavisProg at gmx.com
Thu Aug 8 15:47:48 PDT 2013


On Thursday, August 08, 2013 15:40:25 H. S. Teoh wrote:
> Are we going to fix this anytime soon (or at all)? If not, we'd better
> start documenting this, since currently enums are being sold as manifest
> constants, and most people would understand that as meaning it's only
> allocated once at compile-time/startup-time. It would leave a very bad
> impression if new users unknowingly end up with a lot of unwanted
> allocations just from using a language feature as-advertised.

There's nothing to fix. It's by design. That _is_ what a manifest constant is 
as far as D is concerned. And if you search for manifest constants online, you 
end up running into stuff that talks about #define in C, which does the same 
thing. So, I don't think that we're doing anything abnormal here. We just have 
to make sure that it's clear in the documentation that that's how manifest 
constants work. I don't know what the documentation currently says though.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list