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


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

更新时间:2025-06-22 14:15: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
  • 如何评价“寡姐”斯嘉丽·约翰逊的身材?

    查看案例

  • 你身边身材最好的女生是什么样?

    查看案例

  • 孩子画过什么画让你非常震惊?

    查看案例

  • 为什么 Go 语言的 Error Handling 被某些人认为是一个败笔?

    查看案例

  • MacOS真的比Windows流畅吗?

    查看案例

  • 为什么 mac mini 的 m4 版本价格这么低呢?

    查看案例

  • 豆包推出 AI 编程,在「编辑模式」下可以直接前端改图和文字,体验如何?对行业会带来怎样的影响?

    查看案例

  • 哪张照片让你觉得刘亦菲美得不可方物?

    查看案例