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


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

更新时间:2025-06-19 04:50:09

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

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
  • Rust 的设计缺陷是什么?

    查看案例

  • 如何将docker目录挂载到宿主机上?

    查看案例

  • Linux下监控流量一般使用什么工具?

    查看案例

  • 为什么bilibili后端要用go来写?

    查看案例

  • 独立游戏的成功率极低,但依然有许多开发者愿意投入数年时间去“孤注一掷”。他们为什么会做出这样的选择?

    查看案例

  • 导师给了1.4W要我给工作室买个主机,是整机还是自己配?

    查看案例

  • 如果是你,你会选择Windows还是Mac?

    查看案例

  • 得了强直性脊柱炎是不是一辈子就完了?

    查看案例