Eric Miller, March 2019
Existing proposals for generics in go2 propose various ways of extending the go language by adding significant new mechanisms and features (type parameters, contracts, new syntax, etc...) to the language. This proposal attempts to accomplish the same goals in a way that is a more natural extension of existing go features, in many cases by relaxing existing constraints in natural ways or building at the intersection of existing features and keywords. Ideally, the goal is to simplify the language at the same time as adding new functionality. That is a very ambitious goal, but is nevertheless one that I believe is worth targeting.
I propose extending go's current struct
type to allow const
fields, including but not limited to const type
fields which are populated with concrete type references when the struct is initialized. Methods can reference const
fields of their reciever in their argume