Automatic typing

Timon Gehr timon.gehr at gmx.ch
Fri Jun 28 07:50:11 PDT 2013


On 06/28/2013 03:44 PM, ponce wrote:
> On Friday, 28 June 2013 at 00:34:54 UTC, JS wrote:
>> Would it be possible for a language(specifically d) to have the
>> ability to automatically type a variable by looking at its use cases
>> without adding too much complexity?
>
> Well ocaml has it (https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner)
> and well it's not all that positive, at least in that language.
>
> Combined with parametric polymorphism it's nice and sound, except it has
> the potential to hide a simple typo a lot further from where it is
> (think mixing up integer operators and FP operators).
> As it break overloading on "leaves", it is the reason ocaml has
> "print_string" and "print_int" which is quite frankly ugly.
>

The type system might be too primitive in that regard. Haskell has 'print'.

> Once you have type inference, the first thing you do to make your code
> readable is to add back type annotations.
>

... at a few places.


More information about the Digitalmars-d mailing list