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


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

更新时间:2025-06-23 17:20:14

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

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
  • 为什么中国主机带宽比美国贵5倍(原来错误的10000倍),比如阿里云?

    查看案例

  • 都是研制核武器,为何只敢动伊朗,对朝鲜确畏首畏尾?

    查看案例

  • 为什么 J***aScript 在国外逐渐用于前端+后端开发,而国内还是只用它做前端?

    查看案例

  • 请问照片里这个人是谁呀?

    查看案例

  • 苹果从 2026 年发布的 macOS 27 起不再兼容任何 Intel Macs,这背后原因有哪些?

    查看案例

  • 折叠屏手机有哪些有用或好玩的功能,你过去不理解,现在离不开?

    查看案例

  • 都说机械键盘手感好,为什么还有那么人买薄膜键盘?

    查看案例

  • 周芷若一个船夫的女儿,容貌真的比得上皇家女子吗?

    查看案例