Go 夜聊

第 8 期:泛型来了!

第 8 期:泛型来了! 录制时间: 2022-05-06 嘉宾:老貘 主持:杨文,欧长坤 本期摘要:这是 Go 夜聊的第八期节目,我们和 Go 语言 101 的作者一起聊了聊期待已久的泛型,我们聊到了为什么需要泛型,设计的优点、讨论时的期望与正式发布时的失望。新出现的类型集是什么?comparable 又是什么?目前的泛型设计在未来还有多大的改进空间? 时间线 00:12 开场 01:10 接触 Go 语言的动机 03:30 编写《Go 101》的原因 04:42 活跃在 Go 语言社区 09:27 独立游戏的行业经历 12:11 用 Go 语言做游戏 13:51 泛型产生的动机,与 Go Generate 的对比 20:21 接口、类型集、类型约束的关系 28:36 类型集与泛型的关系 30:40 接口与类型集是同一个概念吗? 31:34 comparable 类型、它能解决什么问题、它还有哪些争议 37:42 接口作为值类型 42:45 泛型设计的其他优点 48:10 泛型设计的缺点 58:09 泛型设计的限制 66:09 对泛型未来的期望与失望 68:20 Go 团队排外吗? 71:35 Go 语言 101 背后的故事 83:38 结尾推荐 87:55 尾声 相关链接 老貘的主页 Go 语言 101 Go 泛型 101 泛型的官方上手教程 观点:类型集和接口不等价 spec: document definition of comparable spec: any no longer implements comparable proposal: spec: permit values to have type “comparable” proposal: spec: permit non-interface types that support == to satisfy the comparable constraint proposal: spec: allow interface types to instantiate comparable type parameters proposal: spec: add new constraint kind satisfied by types that support == (including interface types) proposal: type parameters are comparable unless they exclude comparable types proposal: the comparable interface represents the comparable subset of run-time values how to update APIs for generics proposal: spec: allow type parameters in methods 追风筝的人 灿烂千阳 群山回唱 理解自由意志 AI 新生 📝 联系我们 来信 hi@talkgo.fm Telegram 听众群