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

2025-06-22 12:40: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
相关阅读
为何说FastAPI已死?

为何说FastAPI已死?

评价为: 标题党 介绍一个我写的小工具吧, 它和 fasta...

2025-06-26
大家都喜欢用什么浏览器?

大家都喜欢用什么浏览器?

在Win11时代,微软丧心病狂地在Edge里面塞入了太多莫名...

2025-06-26
中国女明星里谁的身材特别好?

中国女明星里谁的身材特别好?

这个话题,我必须得提名这个女人:袁立阿姨。 还不了解她身材...

2025-06-26
有哪些「性别限制了我的想象力」的例子?

有哪些「性别限制了我的想象力」的例子?

刷到一个帖子,女孩160cm,88斤穿不进S码的衣服,于是抨...

2025-06-26
周杰伦为什么不告粥饼伦黑伦侵犯他的名誉权?

周杰伦为什么不告粥饼伦黑伦侵犯他的名誉权?

关于粥饼伦、黑伦等模仿者,周杰伦本人去年曾经公开回应过,他的...

2025-06-26