gogenericsdesign-documents

Is a new proposal of generics backward compatible with older versions


Among many new things in the recent proposal about adding generic programming for Golang there is a new keyword any

So if my current program has declared a variable named any it won't compile.


Solution

  • in the recent proposal about adding generic[s ...] there is a new keyword any.

    Wrong. any will be a predaclared identifier not a keyword.

    So if my current program has declared a variable named any it won't compile.

    No, of course not, it will just redeclare any in the current scope.

    The list of keywords in Go is pretty short, see https://golang.org/ref/spec#Keywords . Keywords are keywords and cannot be used for other things. A predeclared identifier (see https://golang.org/ref/spec#Predeclared_identifiers) is not a keyword and can be redeclared.