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

2025-06-22 17:15:11

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

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
相关阅读
2025年6月,到底买油车还是电车?

2025年6月,到底买油车还是电车?

我的油车 15年的阿特兹 一年油费4000 保险3100 保...

2025-06-22
如何看待Ghost Cell?(Rust)?

如何看待Ghost Cell?(Rust)?

试用了下 GhostCell [1,2] + StaticR...

2025-06-22
我的世界怎么租一个四个人的服务器?

我的世界怎么租一个四个人的服务器?

我个人是用的阿里云做的内网穿透,阿里云有个峰值带宽200M不...

2025-06-22
俄罗斯为什么不用苏57?

俄罗斯为什么不用苏57?

因为穷。 歼-20首飞是2011年,在密集试飞测试后,20...

2025-06-22
各位历史发烧友,介绍一下你知道的冷门史实或逆天史实?

各位历史发烧友,介绍一下你知道的冷门史实或逆天史实?

本人作为一个历史爱好者,发现了三个基本事实。 第一,所有的...

2025-06-22