What’s Wrong with OOP and FP

bearophile bearophileHUGS at lycos.com
Tue Nov 12 04:27:26 PST 2013


Paulo Pinto:

> What I miss still in languages like D, is the Hindley–Milner 
> type inference, algebraic data types and pattern matching.

Global type inference is too much complex in D, because of 
Turing-complete templates, OOP, very weak interfaces between 
modules in presence of separate compilation, etc, so it can't be 
done or it will become too much hard/complex/slow to do, so it's 
better to forget about it. Also, even in Haskell it's a good 
practice to write down the type signature of all global functions.

The algebraic data types are handy, and Algebraic should improve 
(and if needed some feature should be added to D to make 
Algebraic better!).

Regarding pattern matching, it introduces a significant 
complexity, but a limited form of it could be a good idea for D, 
with improvements in the switch and introducing an optional 
standard method unapply for structs and classes:
https://d.puremagic.com/issues/show_bug.cgi?id=596

Bye,
bearophile


More information about the Digitalmars-d mailing list