I really like to stretch the capabilities of Haxe language...
I think that a very interesting extension of the inferencer would be typedef
Union so that we could use the duck typing this way:

class Peon {
    public    function    new()    {
    }
    public function say ()    {
    }
    public function die ()    {
    }
    public    function sleep ()    {
    }
}

typedef SayDie = {    say : Void -> Void, die : Void -> Void    }
typedef Sleep = {    sleep : Void -> Void    }

var l = new List<SayDie, Sleep>();
l.add(peon);

OR
...
typedef SleepSayDie = {    SayDie, Sleep  }

var l = new List<SleepSayDie>();
...

I know that this is not type classes under the hood (no dictionnaries) but
it is not so far from a user perspective and would gives us a lot of
facilities...
The main advantage compared to interface is that it is completly external to
the class; you don't need to create an interface and make classes derive
from them to capture a specific set of methods/fields (Even Haskell needs to
add the deriving clause; due to its lack of duck typing).

I think such a feature would be so great! :)
Do you think so?
-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to