Index: doc/theses/jiada_liang_MMath/test1.cfa
===================================================================
--- doc/theses/jiada_liang_MMath/test1.cfa	(revision f125e96261b5e9f843f33f69d06cecc8321adc08)
+++ doc/theses/jiada_liang_MMath/test1.cfa	(revision 5ca5263a35da9489b8df7cb34be649df69def763)
@@ -1,4 +1,5 @@
 #include <fstream.hfa>									// sout
 #include <stdlib.hfa>									// ato
+#include <enum.hfa>
 
 // integral
@@ -9,4 +10,5 @@
 enum( Letter ) Greek { Alph = A, Beta = B, Gamma = G, /* more enums */ Zeta = Z }; // alphabet intersection
 
+// integral
 enum( char ) Currency { Dollar = '$', Cent = '¢', Yen = '¥', Pound = '£', Euro = 'E' }; // iso-latin-1
 enum( Currency ) Europe { Euro = Currency.Euro, Pound = Currency.Pound };
@@ -33,9 +35,14 @@
 
 enum() Mode { O_RDONLY, O_WRONLY, O_CREAT, O_TRUNC, O_APPEND };
-Mode iomode = O_RDONLY;
-//bool b = iomode == O_RDONLY || iomode < O_APPEND;	// disallowed
-//int www = iomode;	// disallowed
+Mode mode = O_RDONLY;
+void opaque() {
+bool b = mode == O_RDONLY || mode < O_APPEND;	// disallowed
+//int www = mode;	// disallowed
+}
 
 enum( char * ) Colour { Red = "red", Green = "green", Blue = "blue"  };
+
+enum E1 { A1, B1, C1 = A1, D1 = B1 };
+enum(float) E2 { A2 = 3.5, B2 = 4.5, C2 = A, D2 = B };
 
 void fred() {
@@ -45,17 +52,23 @@
 //greek = A;								// disallowed
 
-	for ( Greek l = Alph; posn(l) <= posn(Gamma); l = succ( l ) ) {
+	for ( Greek l = Alph; posn(l) < posn(Gamma); l = succ( l ) ) {
 		printf( "%s %c %d\n", label( l ), value( l ), posn( l ) );
 	}
-	for ( Currency c = Dollar; posn(c) <= posn(Currency.Euro); c = succ( c ) ) {
+	for ( Currency c = Dollar; posn(c) < posn(Currency.Euro); c = succ( c ) ) {
 		printf( "%s %c %d\n", label( c ), value( c ), posn( c ) );
 	}
 }
 
-
-enum( char * ) Names { Fred = "FRED", Mary = "MARY", Jane = "JANE" };
-enum( char * ) Names2 { inline Names, Jack = "JACK", Jill = "JILL" };
-enum( char * ) Names3 { inline Names2, Sue = "SUE", Tom = "TOM" };
-
+enum( const char * ) Names { Fred = "FRED", Mary = "MARY", Jane = "JANE" };
+enum( const char * ) Names2 { inline Names, Jack = "JACK", Jill = "JILL" };
+enum( const char * ) Names3 { inline Names2, Sue = "SUE", Tom = "TOM" };
+void bar() {
+	Names fred = Names.Fred;
+	(Names2)fred;  (Names3)fred;  (Names3)Names2.Jack;  // cast to super type
+	Names2 fred2 = fred;  Names3 fred3 = fred2; // assign to super type
+	const char * name = fred;
+	Names name = Fred;
+	sout | name | label( name ) | posn( name ) | value( name );
+}
 void f( Names n ) { sout | "Name" | posn( n ); }
 void g( Names2 );
@@ -63,9 +76,17 @@
 void j( char * );
 
-enum color { red, blue, green };
-//color c = 0;
-//color c = 1;
-color c = 2;
-int w = red;
+enum CColour { Red, Blue, Green };
+CColour c0 = 0;
+CColour c1 = 1;
+CColour c = 2;
+int w = Red;
+
+void coo() {
+	enum(int) Color { Red, Blue, Green };
+	Colour c = Red;
+	sout | countof( Colour ) | Countof( c );
+//	sout | Countof( Colour );
+	sout | countof( c );
+}
 
 // enum(int) Week ! { Mon, Tue, Wed, Thu = 10, Fri, Sat, Sun };
@@ -79,12 +100,57 @@
 // }
 
+void baz() {
+	enum(int) Count { First, Second, Third/* = First*/, Fourth/* = Second*/ };
+	enum CCount { First, Second, Third/* = First*/, Fourth/* = Second*/ };
+	Count cnt = Second;
+	CCount ccnt = Second;
+	if ( cnt < Third ) sout | "less than Third";
+	if ( cnt ) sout | "XXX";
+	if ( ccnt ) sout | "YYY";
+	enum(float) F {WWW = 0.0};
+	F f;
+	if ( f ) sout | "FFF";
+	bool ?!=?( Name n, zero_t ) { sout | "DDD";  return n != Fred; }
+	Name n = Mary;
+	if ( n ) sout | "NAME";
+	choose( cnt ) {
+		case First: sout | "First";
+		case Second: sout | "Second";
+		case Third: sout | "Third";
+		case Fourth: sout | "Fourth";
+	}
+//	for (d; Week) { sout | d; }
+//	for (p; +~=Planet) { sout | p; }
+	for ( cx; Count ) { sout | cx | nonl; } sout | nl;
+	for ( cx; +~= Count ) { sout | cx | nonl; } sout | nl;
+	for ( cx; -~= Count ) { sout | cx | nonl; } sout | nl;
+	for ( Count cx = lowerBound();; ) {
+		sout | cx | nonl;
+	  if ( cx == upperBound() ) break;
+		cx = succ( cx );
+	}
+	sout | nl;
+}
+
 int main() {
 	fred();
-	Names name = Fred;
+	Names name = Names.Fred;
 //	f( name );
 
 	int jane_pos = posn( Names.Jane );
-	char * jane_value = value( Names.Jane );
-	char * jane_label = label( Names.Jane );
+	const char * jane_value = value( Names.Jane );
+	const char * jane_label = label( Names.Jane );
 	sout | Names.Jane | posn( Names.Jane) | label( Names.Jane ) | value( Names.Jane );
+
+	bar();
+	baz();
+	coo();
+
+	enum Ex { Ax, Bx, Cx, Nx };
+	float H1[Nx] = { [Ax] : 3.4, [Bx] : 7.1, [Cx] : 0.01 }; // C
+//	float H2[Ex] = { [Ax] : 3.4, [Bx] : 7.1, [Cx] : 0.01 }; // CFA
+
+	enum(int) E { A = 3 } e = A;
+	sout | A | label( A ) | posn( A ) | value( A );
+	sout | e | label( e ) | posn( e ) | value( e );
 }
