2013-01-10 20:50:42 +00:00
|
|
|
void(string, ...) print = #1;enum {
|
|
|
|
// this behaviour is confusing, but I like that
|
|
|
|
// we support it.
|
|
|
|
__ = (__ - 1),
|
|
|
|
A = (__ + 1),
|
|
|
|
|
|
|
|
B,
|
|
|
|
C
|
|
|
|
};
|
2013-01-10 20:38:17 +00:00
|
|
|
|
|
|
|
enum {
|
2013-01-10 20:50:42 +00:00
|
|
|
D = C + B,
|
|
|
|
E = C + C,
|
|
|
|
F = C + D,
|
2013-01-10 20:38:17 +00:00
|
|
|
};
|
|
|
|
|
2013-01-10 20:50:42 +00:00
|
|
|
enum {
|
|
|
|
G = (B + F), H = (C + F),
|
|
|
|
I = (D + F), J = (B + I)
|
|
|
|
};
|
|
|
|
enum {
|
|
|
|
K = A + B - C + D - E + F *
|
|
|
|
G - H + I - J + A - B -
|
|
|
|
J + A,
|
|
|
|
L,
|
|
|
|
M,
|
|
|
|
N
|
|
|
|
};
|
2013-01-10 20:38:17 +00:00
|
|
|
|
Implemented concept of enumeration attributes (can be further extended, but currently only "flag" is implemented as an attribute). An enumeration with a flag attribute will act as a "flagged enumeration", one that automatically handles exponentiation of the constants defined inside it, i.e enum : flag { A, B, C }, A,B,C will equal 2, 4, 8.
2013-03-08 08:01:45 +00:00
|
|
|
enum : flag {
|
|
|
|
F1, /* = 1 << 1 */
|
|
|
|
F2, /* = 1 << 2 */
|
|
|
|
F3 /* = 1 << 3 */
|
|
|
|
};
|
|
|
|
|
2013-01-10 20:38:17 +00:00
|
|
|
void main() {
|
2013-01-10 20:50:42 +00:00
|
|
|
print(ftos(A), "\n");
|
|
|
|
print(ftos(B), "\n");
|
2013-01-10 20:38:17 +00:00
|
|
|
print(ftos(C), "\n");
|
2013-01-10 20:50:42 +00:00
|
|
|
print(ftos(D), "\n");
|
|
|
|
print(ftos(E), "\n");
|
|
|
|
print(ftos(F), "\n");
|
|
|
|
print(ftos(G), "\n");
|
|
|
|
print(ftos(H), "\n");
|
|
|
|
print(ftos(I), "\n");
|
|
|
|
print(ftos(J), "\n");
|
|
|
|
print(ftos(K), "\n");
|
|
|
|
print(ftos(L), "\n");
|
|
|
|
print(ftos(M), "\n");
|
|
|
|
print(ftos(N), "\n");
|
Implemented concept of enumeration attributes (can be further extended, but currently only "flag" is implemented as an attribute). An enumeration with a flag attribute will act as a "flagged enumeration", one that automatically handles exponentiation of the constants defined inside it, i.e enum : flag { A, B, C }, A,B,C will equal 2, 4, 8.
2013-03-08 08:01:45 +00:00
|
|
|
|
|
|
|
print(ftos(F1), "\n");
|
|
|
|
print(ftos(F2), "\n");
|
|
|
|
print(ftos(F3), "\n");
|
2013-01-10 20:50:42 +00:00
|
|
|
};
|