Implementing a Programming Language in D: Lexical Analysis
Ali Çehreli via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Dec 28 22:35:41 PST 2015
On 12/28/2015 09:57 PM, Ali Çehreli wrote:
> anonymous enums
Wow! They are pretty weird:
1) The second form of the AnonymousEnumDeclaration spec is redundant, right?
http://dlang.org/spec/enum.html#AnonymousEnumDeclaration
enum : EnumBaseType { EnumMembers }
enum { EnumMembers } <-- Redundant?
enum { AnonymousEnumMembers }
The reason is, AnonymousEnumMembers already covers EnumMembers, no?
2) Anonymous enum definitions can have types right inside the list:
AnonymousEnumMember:
EnumMember
Type Identifier = AssignExpression
enum {
a,
ulong b = 42, c, // b and c are ulong
s = "hello", // an inferred string between integrals!
x = 7, y, z
}
3) The types of x, y, and z are 'int' because 7 is an int (they don't
follow the type of 'c'). However, move 's' to the end of the list or
remove it altogether, then x, y, and z become ulong! Weird. Ok, I'm
going to forget about this feature now. :p
Ali
More information about the Digitalmars-d-announce
mailing list