I have been troubled by the semantics of vals for a while.
But now I have some progress! Consider:
var x = 1;
val y = x;
var z1 = y;
++x;
var z2 = y;
++x;
Now, val can be calculate "as control passes through" (eagerly).
Or it can be evaluated "when used" (lazily).
So:
z1 must have value 1, z2 m
Well this surprised me a bit, this is reading pchannels:
val m1 = read(inp);
val m2 = read(inp);
val m3 = read(inp);
eprintln$ "Mainline Read1="+ m1.str;
eprintln$ "Mainline Read2="+ m2.str;
eprintln$ "Mainline Read3="+ m3.str;
Mainline Read1=36
Mainline Read2=16
Mainline