你现在的位置是:当前位置: 首页 >


大部分语言都用尖括号<>表示泛型,为什么golang要标新立异用中括号?

更新时间:2025-06-21 20:05:16

最新的设计文档里面对这一块做了一个解释。

Why not use the syntax F like C++ and J***a? When parsing code within a function, such as v := F, at the point of seeing the < it's ambiguous whether we are seeing a type instantiation or an expression using the < operator. This is very difficult to resolve without type information. For example, consider a statement like a, b = w < x, y > (z) Withou…。

大部分语言都用尖括号<>表示泛型,为什么golang要标新立异用中括号?

案例推荐

case recommendation
  • 如何评价腾讯云SDK的GO语言仓库有20万个tag?

    查看案例

  • JetBrains 放弃 AppCode 是否是一个错误决定?

    查看案例

  • 为什么这么久了还是没有主流软件开发鸿蒙版?

    查看案例

  • Python+rust会是一个强大的组合吗?

    查看案例

  • 如果看待林丹这句话 “网球的强度远远没有羽毛球大”?

    查看案例

  • 为什么不建议在 Docker 中跑 MySQL?

    查看案例

  • 为何 Linus 一个人就能写出这么强的系统,中国却做不出来?

    查看案例

  • 可以随身携带一个Linux系统吗?

    查看案例