Just so you get it: fun f x:int) (y:int) => x + y;
var y = 100; var x = 1; var g = f x; ++x; var k = g y; println$ k; ~/felix>build/release/host/bin/flx --test=build/release ab 102 See? x is a val, f was inlined. Now fun f (var x:int) (y:int) => x + y; var y = 100; var x = 1; var g = f x; ++x; var k = g y; println$ k; ~/felix>build/release/host/bin/flx --test=build/release ab 101 See? var forces eager evaluation. So I think you're very confused, because g is a closure you expect eager evaluation in both cases. What you get: the argument *to* the closure, y, is eagerly evaluated. See this: fun f (x:int) (y:int) () => x + y; var y = 100; var x = 1; var g = f x; ++x; var k = g y; y = y + y; println$ k (); ~/felix>build/release/host/bin/flx --test=build/release ab 102 See? It uses the value of y at the time the closure is applied. A function*creating* a closure doesn't necessarily use eager evaluation (unless the parameter is a var). The closure itself does, however (at present). Its very simple. When you inline a function with a var parameter the code starts of with var parameter = argument; That's it. With a val, it MIGHT replace the parameter with the argument in the body of the inlined code. In effect it says val parameter = argument; and you know that the word "parameter" in the body might be replaced by the expression "argument" (lazy evaluation). For non-inlined code we have ordinary C++ function or methods so the evaluation is eager because it is in C/C++. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language