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

2025-06-23 03:45:14

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

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要标新立异用中括号?
广告位810*200
相关阅读
服务器能否拒绝非浏览器发起的HTTP请求?

服务器能否拒绝非浏览器发起的HTTP请求?

有一个很新的东西,叫做tls指纹,服务器可以根据这个判断是否...

2025-06-22
中国的歼35A可以吊打十架韩国的KF21吗?

中国的歼35A可以吊打十架韩国的KF21吗?

首先说结论一架歼-35A吊打最少100架KF21,为什么这么...

2025-06-22
皮肤太白是种怎样的体验?

皮肤太白是种怎样的体验?

大概就是 只要给我一点光 我就是灯泡! 废话不多说,直接上图...

2025-06-22
为何雷军天天健身,却无健身痕迹?

为何雷军天天健身,却无健身痕迹?

因为他撒谎了! 他说他跑步,月均300公里。 对,不跑步的人...

2025-06-22
为什么有的女生喜欢穿紧身牛仔裤?

为什么有的女生喜欢穿紧身牛仔裤?

个人觉得,女生穿牛仔裤的形式意义还是大于内容 说白了,就是审...

2025-06-22