arrow
Return

Welterweight Go: Boxing, Structural Subtyping, and Generics

delete2026-01-01
delete0
PRE
AI
R
Raymond Hu *
J
Julien Lange
B
Bernardo Toninho
P
Philip Wadler
R
Robert Griesemer
K
Keith H. Randall
DOI:10.1145/3776721delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
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.
Keywords:
Go
Generics
Boxing

Journal

P
Proceedings of the ACM on Programming Languages-PACMPL
IF:
2.8
Papers:
308
Citations:
4.7K

Organization

Q
Queen Mary University London
Scholars:
2.0W
Papers: 1.5W
Citations: 327
I
inesc-id
Scholars:
636
Papers: 504
Citations: 0
U
university of london
Scholars:
21.5W
Papers: 19.7W
Citations: 305
U
Universidade de Lisboa
Scholars:
3.2K
Papers: 1.5K
Citations: 1
researcher View more organizations