On 18/05/2012, at 9:54 AM, john skaller wrote: > > On 18/05/2012, at 3:47 AM, Raoul Duke wrote: > >> otherwise known as structural typing? > > Well we could say > > interface Fred { > getx: 1 -> int; > };
BTW: .. records can be polymorphic so .. interface Fred[T] { ... However Felix objects cannot be polymorphic. However object X[T] implements Fred[T] ... isn't an object, it's a function :) So actually this works! //////////////////////////////////// fun Y[T] (var y:T) = { fun gety() => y; return (gety=gety); } var aYint = Y(2); var aYdouble = Y(2.2); println$ aYint.gety(); println$ aYdouble.gety(); //////////////////////////////// which is already better than anything Java can do. Note the actual objects constructed cannot be polymorphic. To make this technology viable, we need to provide a couple of operations on record types. Since they're sets of fields, it's basically union, difference, etc. Ignoring polymorphism and decisions about conflicts (such as: how to merge two record types with the same field name .. use exclusive or??) the implementation in the compiler is trivial list processing (and would be even more trivial if the Ocaml representation of records was actually a Set.t ... but lists will do :) The only hard bit is overloading to provide automatic conversions. Eg if you have a function taking a record (a:int, b:double) a record with any extension of this will do. This matching is specific to records. Hopefully it won't be confused with the existing way to call any function with a record value argument (named arguments feature). The matchability is trivial of course, we can make better matching based on the obvious "matches more fields". In the first instance. In the second instance .. we have to take polymorphic specialisation into account as well .. two kinds of subtyping. Note that we're talking of doing this row polymorphic subtyping stuff only for overloads NOT for closures: there you would need an explicit coercion to get the type right. -- 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