Idea: Reverse Type Inference

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Mon May 22 06:20:41 PDT 2017


On Monday, 22 May 2017 at 10:13:02 UTC, Sebastiaan Koppe wrote:
> I work with Scala professionally. I often feel its type 
> inference for generics/templates is better than D's; as long as 
> it can find a type _anywhere_ it will use that, no matter where 
> it needs to pull it from.

And how long does that code take to compile ?

type inference is not magic, it's a search for a pattern over the 
syntax (sub)tree.
Hence it can have quadratic time/memory complexity.

Additionally it's harder to prove sound, i.e. there is more 
potential for undetected bugs,
As well as making it more surprising when the inference fails.




More information about the Digitalmars-d mailing list