~/talk

How Go Avoided the Integer Promotion Footgun

Talkat GopherCon Europe 2021 · 2021-05-26..05-28· [go, compilers-and-language-design]
slides:none on file

Explains why Go avoids the C-style integer promotion footgun by making literal numbers untyped constants so 1<<32 can represent 4GB without truncation on 64-bit platforms and cause a compile-time error instead of undefined wraparound on smaller words; shows C examples where int-typed literals produce surprising results (e.g. signed char wrapping to -128, 256 truncating to 0) and demonstrates typed constants with methods to encode units rather than rely on suffixes like 0x80ULL.

AI-written summary · about

  1. 0:00Start
  2. 4:13Mark 1 fire control computer 1940ish
  3. 5:09IBM 407 Accounting Machine 1949
  4. 9:45Control Data 6600 1964
  5. 12:49BPCL Martin Richards, 1967
  6. 13:41B Ken Thompson, 1969
  7. 16:03Computers evolved various word sizes for market segmentation reasons
  8. 17:34The C Programming Language First Edition, 1978
~/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.