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

2025-06-21 13:15: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要标新立异用中括号?
广告位810*200
相关阅读
现在读写速度最快的硬盘,能在30年前的计算机上当做内存使用吗?

现在读写速度最快的硬盘,能在30年前的计算机上当做内存使用吗?

你怕是对内存有什么误解? 哪怕是30年前,哪怕速度不及固态零...

2025-06-20
golang 与rust 在服务器程序领域相比较,各有什么优劣势?

golang 与rust 在服务器程序领域相比较,各有什么优劣势?

Rust 高级,可维护性高,Golang 低级,写出来东西快...

2025-06-20
福州人口流出为什么这么严重?

福州人口流出为什么这么严重?

服务端厦门薪水会平均比福州高5k,24年。 说下2w梯队的...

2025-06-20
你卡过最厉害的bug是什么?

你卡过最厉害的bug是什么?

我娃卡出来的bug, 现在的孩子吧,给手机就不好好学习。 不...

2025-06-20
能分享一下你写过的rust项目吗?

能分享一下你写过的rust项目吗?

实际工作中,2020年的时候用 Rust 在 ARM 设备上...

2025-06-20