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


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

更新时间:2025-06-19 08:50:12

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

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
  • 柳州的债务,谁来还?用什么还?怎么还?

    查看案例

  • 你见过最无用的节俭行为是什么?

    查看案例

  • 自己组一个E5服务器才几百块钱,为什么去阿里云租这么贵?

    查看案例

  • 什么是 AI Agent(智能体)?

    查看案例

  • 为什么中国人做一顿饭要几个小时,而国外花的时间少得多?

    查看案例

  • 为什么盗版音乐已经被严格限制了,而中国音乐却还是没有发展起来?

    查看案例

  • 63 岁演员马景涛直播时突然晕倒、后脑勺磕地,合作方称其突发低血糖,为什么会这样?如何急救?

    查看案例

  • 特斯拉宣布将于 6 月 22 日开始 Robotaxi 公开试运营,这将对自动驾驶行业带来哪些影响?

    查看案例