大部分语言都用尖括号<>表示泛型,为什么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
相关阅读
PHP现在真的已经过时了吗?

PHP现在真的已经过时了吗?

一个社区语言能泛起多大浪花?PHP30周年线上活动PHPve...

2025-06-19
网络小白如何建立一个网站,供别人下载文件(主要是PDF和MP3)?

网络小白如何建立一个网站,供别人下载文件(主要是PDF和MP3)?

我估计了一下,大概可以做到百元以内,大概率免费。 使用Clo...

2025-06-19
前端如何设计网页?

前端如何设计网页?

2025年6月,苹果在WWDC 2025上发布了令人惊艳的i...

2025-06-17
你的亲戚提过什么过分的要求?

你的亲戚提过什么过分的要求?

24年末,我花了几千配了一台台式电脑主机,因为原来的那台已经...

2025-06-19
不是都说6月美债要爆吗 怎么没消息了?

不是都说6月美债要爆吗 怎么没消息了?

因为财政部自己回购了200亿美元的美债,金额史上最大,相当于...

2025-06-17