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

2025-06-19 19:25: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
相关阅读
你为什么选择了flutter?

你为什么选择了flutter?

春节期间研发了一款 flutter3.27+dart3高仿抖...

2025-06-22
什么是bootloader?

什么是bootloader?

在2016年,我在做一个网关项目时,需要实现远程固件升级功能...

2025-06-22
巴基斯坦援助伊朗防空,大家怎么看?

巴基斯坦援助伊朗防空,大家怎么看?

这明显就是东大给的指示,但不管援助给多少,伊朗如果做不到死战...

2025-06-22
如果现在南京市整体穿越到1937年,能守住南京吗?

如果现在南京市整体穿越到1937年,能守住南京吗?

这里首先限定,本回答***设2025年6月1日的南京市行政范...

2025-06-22
大家买的房子都跌了多少呀?

大家买的房子都跌了多少呀?

坐标广州番禺,番禺广场片区。 92.7平方,2018年购入...

2025-06-22