~/talk

Generics Unconstrained!

Talkat GopherCon UK 2022 · 2022-08-16..08-18· [go]
links:none on file
slides:none on file

Claim: prefer unconstrained type parameters combined with existing Go features because they produce simpler, more general APIs. Shows concrete rewrites: strings.Join becomes generic by passing a toString mapping function instead of a Stringer constraint; a directed-graph API drops mutually recursive Node/Edge constraints in favor of a generic interface to encapsulate recursive relationships; and outer containers drop type parameters via type erasure using a non-generic interface. Notes Min/Max still needs a constrained ordered set.

AI-written summary · about

  1. 0:00Intro
  2. 0:26Overview
  3. 1:12The type parameters proposal
  4. 1:44Type parameters 101
  5. 5:41Existing polymorphism
  6. 6:28Type parameterised polymorphism
  7. 8:55Where does the complexity of the spec come from?
  8. 12:46Stringer Join
  9. 15:04Unconstrained Join in practice
  10. 16:28Example 2: Directed graph traversal
  11. 20:29Unconstrained graph implementation
  12. 24:47Hiding type parameters
  13. 25:04Type erasure
  14. 27:11Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.