I've now implemented value extensions. The syntax is temporary
just to get stuff working.

/////
var x = (a=1, b=2);
var y = (c=9.9, s="Hello");

var xyz = extend x,y with (k="world") end;

println$ xyz.a, xyz.b, xyz.c, xyz.s, xyz.k;
////


Note syntactic quirkology: x,y means value x, then value y, it doesn't mean
the tuple x,y.

extend v1, v2, ... vn with v end

merges the field of all the records v1 to vn and v together to make a new
record, again throwing out duplicate names so the "last mentioned" is kept.

This same syntax is ALSO a type expression when used in a type context.

Note there's no particular reason for extending a list followed by one special
case .. other than that's what Java and most OO languages do when deriving
something new with multiple "bases".

Now, the main reason for implementing this thing is to make it possible
to somehow make objects like this:

fun makeD (b1: Base1, b2:Base2, var x; int) =>
    extend b1, b2 with (getx= fun getx () => x) end
;

which is an implementation of D, which extends Base1 and Base2.
I don't have a "object" syntax for that yet -- the first step is to have some
kind of cake, before you can put the icing on.

--
john skaller
skal...@users.sourceforge.net
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
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to