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 may be 1 OR 2 but NOT 3.

SO: instead of banning use of variables in initialisers of vals,
such as y above, we actually require only that between the definition
and uses (particularly the "last use"), the variables merely remain
invariant.

At present, the compiler actually tries to calculate this, and uses lazy
evaluation only when the variable at the point of definition hasn't
changed.

Actually it would be nice to remove those tests, and place the onus
on the user to get it right: generate a warning or whatever if
possible, but don't try to enforce seemingly sane semantics.

The reason is: the semantics are NOT enforced this way for
argument passing anyhow (and that's initialisation).

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to