Type Inference Algorithm

What type selection algorithm does the Go compiler use?

I tried looking at golang but I can not find the documentation. I am tempted to suggest that it will be Hindley-Milner, but I would like to know for sure

+6
source share
1 answer

Go certainly does not use the Hindley-Milner. Why do you think so? In fact, Go does not have type inference at all , only with the construction := and uses an extremely simple rule for accepting the evaluated type on the right side and applying it to the newly declared variable on the left. Actually, this is pretty damn similar to the C ++ 11 auto keyword (except for const rules and references).

+21
source

Source: https://habr.com/ru/post/926234/


All Articles