Writing the tutorial I have noted you can do this:
var a = (b + c as var d) + 1;
and also this:
var a = (var b + c) + 1;
The "expr as var x" syntax is an extension of
expr as x
which creates a val in an executable expression (rather than a var).
This is basically a side effect of the syntax for type expressions:
typedef list = 1 + int * x as x;
which defines a recursion with a temporary variable, however in the executable
expression case the variable isn't temporary. The type expression syntax is
from Ocaml.
I find this a bit weird, this would seem to make more sense:
var a = (var d = b + c) + 1;
Not however you cannot do this:
var x = (a = 3) + 1;
because that actually creates a record with field a set to 3
and then fails because you cannot add 1 to it :)
However we could support the general assignment operator "def":
var x = (def a, var b, val c = 1,2,3);
At present, Felix doesn't allow things like:
var x = i++;
because i++ is regarded as a statement. It's a bit weird to ban that,
but allow a variable assignment, even weirder to allow a binding
inside an expression!
We have a minor mess here. Originally Felix was specifically design
to *prevent* any kind of side effects in expressions. We wanted transparency.
But generators break this, and now we have variable initialisations,
but not assignments or other things. Note that a variable binding isn't
a mutator in the sense that it isn't modifying a variable, it's initialising it.
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language