Search papers, labs, and topics across Lattice.
This paper introduces WG (Welterweight Go), a core model of the Go programming language that effectively captures its complex structural subtyping and generics, addressing limitations of previous models. The authors also present LWG, a lower-level language that accurately represents Go's runtime mechanisms, including the critical distinction between raw struct values and interface values with runtime type information (RTTI). Their type-directed compilation from WG to LWG successfully implements new features while ensuring compatibility with separate compilation and avoiding runtime code generation, marking a significant advancement in Go's formalization.
Go's unique structural subtyping and generics can now be formally captured without sacrificing runtime efficiency or compatibility with existing compilation practices.
Go's unique combination of structural subtyping between generics and types with non-uniform runtime representations presents significant challenges for formalising the language. We introduce WG (Welterweight Go), a core model of Go that captures key features excluded by prior work, including underlying types, type unions and type sets, and proposed new features, such as generic methods. We also develop LWG, a lower-level language that models Go's runtime mechanisms, notably the distinction between raw struct values and interface values that carry runtime type information (RTTI). We give a type-directed compilation from WG to LWG that demonstrates how the proposed features can be implemented while observing important design and implementation goals for Go: compatibility with separate compilation, and no runtime code generation. Unlike existing approaches based on static monomorphisation, our compilation strategy uses runtime type conversions and adaptor methods to handle the complex interactions between structural subtyping, generics, and Go's runtime infrastructure.