Skip to content

Instantly share code, notes, and snippets.

View HALtheWise's full-sized avatar

Eric Miller HALtheWise

  • Olin College of Engineering
  • Needham, MA
View GitHub Profile

go2 proposal: simple generics using const struct fields

Eric Miller, March 2019

Motivation

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.

Overview

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

@HALtheWise
HALtheWise / keybase.md
Created May 4, 2018 02:36
Keybase Identity Proof

Keybase proof

I hereby claim:

  • I am halthewise on github.
  • I am halthewise (https://keybase.io/halthewise) on keybase.
  • I have a public key ASCTbIlXXl_z_ZA5sb24IikYSVts-yjKlleQZ8Zt_yRXEAo

To claim this, I am signing this object: