How about "auto" parameters?

bearophile bearophileHUGS at lycos.com
Tue Jun 7 09:49:59 PDT 2011


Andrei:

> There are multiple issues. One is we don't have Hindley-Milner 
> polymorphism. The D compiler doesn't really "infer" types as "propagate" 
> them.

- Even Scala, that has a very powerful type system (far more complex than D) doesn't use H-M, I think because they prefer type inference inside methods, but explicit specification of interfaces.
- H-M is good but it's not perfect. Haskell is fighting since years against the limitations imposed by H-M. There are many extensions to Haskell, but they often overflow the inferencing capabilities of H-M.
- I am not expert but I think H-M doesn't work well with C++-style polymorphism. Haskell use type classes.
- My experience with Haskell is limited still, but while I like its type inference, I generally prefer to give some kind of types to functions. Even in Haskell code written by expert people I see several explicit type signatures. In the end I don't feel a need for full program type inferencing in D.
- I don't remember what ATS language uses, if it performs whole program type inference. I doubt it.


> Another is, such inference would make separate compilation difficult.

I think there are ways to solve this problem, introducing more powerful module interfaces. But such modules are not easy to use (see ML).

-------------------------------

foobar:

> We don't Hindley-Miler _yet_. I can hope, can't I? 

I don't think you will see H-M in D, I think it goes against D templates.

Bye,
bearophile


More information about the Digitalmars-d mailing list