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


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

更新时间:2025-06-20 15:55:18

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

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
  • 如何看待不超过1879元的Mac mini(M4+16/256GB+票),易用性吊打同级其他台式电脑?

    查看案例

  • 汉语是牺牲了什么,才成为世界最紧凑、最高效的语言?

    查看案例

  • 你们的腰突是怎么突然好的?

    查看案例

  • 只能选一个,你选谁?

    查看案例

  • 微软暂停专用 Xbox 掌机开发,转而优化 Windows 11 的掌机游戏体验,这背后原因有哪些?

    查看案例

  • 为什么腾讯云或者阿里云不让自建dns服务器?

    查看案例

  • 腾讯开源的 libco 号称千万级协程支持,那个共享栈模式原理是什么?

    查看案例

  • 自己拥有一台服务器可以做哪些很酷的事情?

    查看案例