[dox] enum specs vs reality

captaindet 2krnk at gmx.net
Wed Aug 28 08:26:03 PDT 2013


On 2013-08-28 02:21, Jacob Carlborg wrote:
> On 2013-08-28 04:27, Andre Artus wrote:
>
>> 2. The example from p.69 [TDPL]. It seems to be missing a colon
>> after "enum". enum size_t g_maxDataSize = 100_000_000, g_maxMemory
>> = 1_000_000_000;
>>
>> I hope someone can clear up what is and isn't a valid enum.
>
> I haven't looked at this in TPL but the above is a manifest constant.
> Which basically has nothing to do with enums. It's a way to declare a
> constant that doesn't have any storage and which address cannot be
> taken. Basically the same as "#define foo 0" in C.

don't know what you mean. since they are defined with the enum keyword they have everything to do with enum, especially the official syntax presented here: http://dlang.org/enum.html

enum keyword covers both, enumeration constants and manifest constants. the specs cover both in one. moreover, they explain that manifest constants are only syntactic sugar for anonymous enums:

enum { A = 2, B = 4 }

is the same as

enum A = 2;
enum B = 4;


More information about the Digitalmars-d mailing list