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

2025-06-20 22:30:16

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

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
相关阅读
为什么程序员独爱用Mac进行编程?

为什么程序员独爱用Mac进行编程?

去闲鱼上搜 MacBook Pro M1,都是某互联网大厂满...

2025-06-19
鱼缸哪里买比较便宜呢?

鱼缸哪里买比较便宜呢?

闲鱼收,很容易捡漏。 但是鱼缸寿命其实挺短的,主要是鱼缸的...

2025-06-19
从零写一个3D物理引擎难度多大?

从零写一个3D物理引擎难度多大?

谢邀~ 如果对物理仿真感兴趣的话,我觉得这个时长是可能是一辈...

2025-06-19
眼睛的飞蚊症,能够康复吗?

眼睛的飞蚊症,能够康复吗?

我是前飞蚊症患者,做了玻璃体切除术后飞蚊已经对我人生再也不产...

2025-06-19
Rust的设计缺陷是什么?

Rust的设计缺陷是什么?

刚看上一个大佬回答的评论区,我认为其实Rust最核心的设计缺...

2025-06-19