On 19/05/2012, at 4:44 PM, john skaller wrote: > > At the moment you have to do this: > > typedef ab = (a:int, bint); > p (z :>> ab); > > i.e. you have to explicitly coerce the record to have the exact fields the > function requires.
Ah, I should add some comments on "polymorphism" here, meaning "like Python or Java or C++ virtual functions". When you do a record coercion it just forgets some fields. So lets have a look: interface Base { p: 1 -> 0; } // aka a procedure interface Derived extends Base { q: 1 -> 0; } object B implements Base { omethod proc p() { println$ "Base"; } } object D implements Derived { omethod p() { println$ "Derived"; } omethod q() { println$ "Something"; } } var aD = D(); proc doit (x:Base) { x.p(); } doit (aD :>> Base); So, what's this going to do? Since we're slicing back the object you'd be tempted to think "Hey, there's no virtual functions here, so it's going to print "Base" which of course SUCKS. But 10 seconds later you realise that's all wrong. Of course it prints "Derived". Object D is completely unrelated to Object B. Stripping the function "q" out of the record has no impact on "p". Indirection is much more powerful than virtual function polymorphism. It has two downsides: * It's expensive compared to virtual functions which typically require only a single vtable pointer in an object * It's TOO powerful, so it's hard to reason about. However its a dang sight better to have this overly powerful and expensive construction that to get stuck with something FAR worse: dynamic typing. We'll get to that. Felix was always meant to be dynamically typed. It is a scripting language after all. However, the way forward I have chosen is: instead of "Python is dynamically typed lets try (in vain) to add optional static typing". That's crap. It can't work. The right way to do it is to do the static typing first. Then provide flexible but statically typed constructions. The more flexible you make them the more closely it resembles dynamic typing, but now we have a range of alternatives. All statically typed languages have dynamic typing in the form of passing around, constructing, and parsing strings. -- 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