~/talk

Generating Generators

Talkat GopherCon Europe 2022 · 2022-07-28..07-31· [compilers-and-language-design, go]
slides:none on file

Implements Python‑style generators for Go by static analysis and code generation: the tool gengen takes functions using a fake yield and emits real Go closures plus a state block, labels and gotos, and a genjen build tag with go:generate so generated code compiles separately. It hoists variable declarations to the state struct, converts blocks to labeled jumps, adapts maps/slices/channels, and runs — demo builds a Fibonacci generator that produces correct values.

AI-written summary · about

  1. 0:00Introduction and context
  2. 1:38The problem of iterators
  3. 4:10Implementing iterators in Go
  4. 7:38Introducing generators
  5. 10:54Building a generator tool
  6. 12:16Control flow transformations
  7. 17:35Modeling control structures
  8. 20:49Fibonacci demo and conclusion
~/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.