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

2025-06-20 16:45: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要标新立异用中括号?
广告位810*200
相关阅读
做好的flask项目怎么部署到服务器,使用公网ip可访问?

做好的flask项目怎么部署到服务器,使用公网ip可访问?

一、生产部署应用开发完成以后,需要把它提供给用户使用。 重点...

2025-06-20
055大驱到底强在哪里?

055大驱到底强在哪里?

现在最令美国破防的不是六代机,也不是中国海军疯狂“下饺子”,...

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

Rust的设计缺陷是什么?

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

2025-06-20
一枚东风41能直接干掉一艘航母吗?

一枚东风41能直接干掉一艘航母吗?

打不掉! 因为东风41发射前要注入坐标,是打固定目标的。 考...

2025-06-20
为什么中国足协成了“过街老鼠”了?

为什么中国足协成了“过街老鼠”了?

因为足协始终没弄明白自己到底该干啥。 组织联赛、谈转播费、...

2025-06-20