3 ms·
These are two entirely different concepts: `any` is a compile-time construct, `interface{}` is a run-time construct. At any specific callsite, `any` resolves in
by majewsky 6y ago
These are two entirely different concepts: `any` is a compile-time construct, `interface{}` is a run-time construct. At any specific callsite, `any` resolves into one specific type that gets passed at that specific callsite. Buy `interface{}` can hold values of different types at the same callsite.
- nixpulvis 6y agoComment on the issue: https://github.com/golang/go/issues/43651#issuecomment-758867068 https://github.com/golang/go/issues/43651#issuecomment-75886... From the proposal: > However, it‘s tedious to have to write interface{} every time you write a generic function that doesn’t impose constraints on its type parameters. So in this design we suggest a type constraint any that is equivalent to interface{}. Further unification possible: https://github.com/golang/go/issues/33232 https://github.com/golang/go/issues/33232 However I do agree this is making it somewhat confusing what is in a static and what is in a runtime position.
- majewsky 6y agoFrom what you quoted: > we suggest a type constraint any that is equivalent to interface{}. That's my point. They chose the keyword any to disambiguate the type constraint interface{} from the type interface{}.