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


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

更新时间:2025-06-24 02:10:15

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

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
  • 贵州榕江县城遭超 30 年一遇洪水威胁,最大商场被洪水淹没,目前当地情况如何?为什么此次洪水这么大?

    查看案例

  • 吴彦祖疯狂接代言被猜缺钱,卖完英语课又代言黄酒,他是真的缺钱还是有其他考量?

    查看案例

  • 为什么以前游戏画质那么差还有那么多人玩?

    查看案例

  • 你在出租房屋发现过什么前租客留下的“宝藏”?

    查看案例

  • 如何评价宝鸡这个城市?

    查看案例

  • 除了厚重,你拒绝折叠屏的理由还有哪些?什么样的折叠屏才能打动你?

    查看案例

  • 搞了NAS之后去哪里下载4K,8K的电影?

    查看案例

  • 像游戏《8番出口》这样的无限迷宫设计,在游戏开发中是如何实现的?

    查看案例