Bug 3999 and 4261

Jonathan M Davis jmdavisprog at gmail.com
Wed Sep 1 12:18:16 PDT 2010


On Wednesday, September 01, 2010 11:58:39 so wrote:
> I have never had troubles with C++ compile/runtime "const" difference,
> and don't think it is a problem in C++. With this in mind "enum" is a
> great keyword
> of choice to express compile-time types, as long as it is forbidden for
> run-time constants.
> (I hope that example of bearophile is just a bug.)
> 
> Thanks.

C++ doesn't have CTFE. CTFE is why it really matters in D. If you're dealing 
with a compile-time constant, it uses CTFE. If you're dealing with a runtime 
constant, it doesn't. So, you need to be explicit.

Personally, I don't really care about using enum the way it is. Having enums 
freely converting to and from their base type is more of a concern, though I'm 
not sure how much that really does or doesn't matter. It's quite clear when an 
enum is used as a manifest constant and when it's used as an enum, so I don't 
really see a problem with the way it is, though I can see why someone wouldn't 
like it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list