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


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

更新时间:2025-06-27 21:25:17

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

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 月 28 日开始下架「Microsoft 远程桌面」应用,背后原因有哪些?

    查看案例

  • 为什么中国主机带宽比美国贵5倍(原来错误的10000倍),比如阿里云?

    查看案例

  • 为什么Rust写个链表都那么难?

    查看案例

  • 电影《碟中谍》系列中哪一部最好?

    查看案例

  • 有哪些事,是社会底层人认识不到的?

    查看案例

  • 不喜欢老婆找健身房男教练私教,是我太狭隘了吗?

    查看案例

  • 为什么至今仍未有任何主流游戏为NPC接入大语言模型LLM?

    查看案例