1.12. Numbered unions

Numbered unions are algebraic types used to represent alternative cases. The infix operator + is the type combinator used to denote them.
Start C++ section to tut/examples/tut207a.flx[1 /1 ]
     1: include "std";
     2: open Long;
     3: 
     4: typedef three = unit +  unit + unit;
     5: typedef four = 4;
     6: typedef nu = int + double + long;
     7: 
     8: 
     9: val x1 = case 1 of (1+1+1);
    10: val x2 = case 2 of 3;
    11: 
    12: proc g(x:three) {
    13:   print "Case ";
    14:   match x with
    15:   | case 1 => { print 1; }
    16:   | case 2 => { print 2; }
    17:   | case 3 => { print 3; }
    18:   endmatch;
    19:   print " of three\n";
    20: }
    21: 
    22: g x1;
    23: g x2;
    24: g (case 3 of three);
    25: 
    26: proc f(x:nu) {
    27:   match x with
    28:   | case 1 ?z => { print "case 1 "; print z; }
    29:   | case 2 ?z => { print "case 2 "; print z; }
    30:   | case 3 ?z => { print "case 3 "; print z; }
    31:   endmatch;
    32:   print "\n";
    33: }
    34: 
    35: val i1 = (case 1 of nu) 33;
    36: val i2 = (case 2 of nu) 3.3;
    37: val i3 = (case 3 of nu) 33L;
    38: f i1;
    39: f i2;
    40: f i3;
    41: 
    42: 
End C++ section to tut/examples/tut207a.flx[1]