www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - syntax of manifest enum

This idea would have been more valuble if I came up with it before D
2.009 came out, but I still post it.

One thing that bug me is that you have to use commas instead of
semicolons. The solution that struck me was to have element in a
sequence separated by commas and unrelated items separated by
semicolons. Element that are separated by commas would have to have
homogenus type (this would prevent sudden changes of type apon switching
form an earlier version).


enum { a = 1U, b = 2 }
typeof(a) == typeof(b);

enum { a = 1; b }
b == 0;

Advantages of this syntax is that enums form version other than 2.009,
won't have their meaning changed.
Jan 02 2008