Type Specialization in Go

Type Specialization in Go.
This post was originally tweets but then things happened, and it needed a new linkable home. Btw, I’m now @commaok@inuh.net on Mastodon.
This post is about manual type specialization, which can make a big difference in some hot code.
Consider this:
type Gopher interface { Goph() } func f(x Gopher) { // … if t, ok := x.(*T); ok { t.Goph() } else { x.Goph() } // … } It’s weird.

Read in full here:

This thread was posted by one of our members via one of our news source trackers.

Corresponding tweet for this thread:

Share link for this tweet.