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


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

更新时间:2025-06-19 02:10:10

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

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
  • 小米YU7从7月提前至6月底发布,是什么原因导致提前发布?

    查看案例

  • 新疆机票价格暴涨,上海飞乌鲁木齐往返超 6000 元,为什么旅游旺季还没到价格就飞涨?新疆旅游有多火?

    查看案例

  • 大家觉得华为鸿蒙系统5.0好用吗?

    查看案例

  • 凤凰传奇曾毅手表被指含性暗示元素,回应「以为是劳力士」,如何看待此事?公众是不是有些过度解读了?

    查看案例

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

    查看案例

  • 为什么 Qt 这么难用?

    查看案例

  • 以总理称已控制伊朗首都领空,领空被控制意味着什么?伊朗还可以通过空袭反击吗?

    查看案例

  • 如何看待华为Pura80标准版手机接口竟倒退成USB 2.0?

    查看案例