So here's object lambdas:
//////////
val x = (a=1, b=2, c="m");
val y = (c=9.9, s="Hello");
typedef X = (a:int, b:int, c:string);
typedef Y = (c:double, s:string);
typedef XYZ = extend X, Y with (k:string) end;
var xyz:XYZ = extend x,y with (k="world") end;
println$ xyz.a, xyz.b, xyz.c, xyz.s, xyz.k;
println$ "Felix Rocks";
var a = object (x:int) = { omethod fun getx()=>x; };
println$ (a 1).getx();
var b = a 2;
println$ b.getx();
var d = (object () = { omethod fun getit() => "it"; })();
println$ d.getit();
////////////
The "no argument" object is a bit messy, you have to use ()
for the argument, and then apply the lambda to () to instantiate it
(remember, we're declaring a function so we have to apply it
to get a record out of it).
I also don't like needing to say
d.getit()
i.e. to have to put the () there, this works too:
#(d.getit)
and of course
getit d ()
.Of couse ..
fun ff (var x:int) = {
return (getx = x);
};
println$ (ff 1).getx;
but that's not getting x, it is x :)
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language