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

2025-06-23 21:50: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
相关阅读
有没有什么路由器让你用过之后彻底惊艳了?

有没有什么路由器让你用过之后彻底惊艳了?

tplink商用版本路由器 路由+交换机+3个大饼AP挂天上...

2025-06-24
notion和Obsidian这两款软件选哪个?

notion和Obsidian这两款软件选哪个?

2025年了不要纠结这种问题,无脑Notion+markdo...

2025-06-24
什么是你去了台湾才知道的事?

什么是你去了台湾才知道的事?

我去过台湾三次,最大的感受是,本来以为两岸同根同源都说普通话...

2025-06-24
现代艺术只考虑意义、不考虑美感吗?

现代艺术只考虑意义、不考虑美感吗?

我认为恰恰相反 你看这幅画,美的无可挑剔! 独特的构图、...

2025-06-24
为什么大部分人都认为2560x1440是2K?

为什么大部分人都认为2560x1440是2K?

长边K,短边P,本来是没争议的。 但不知是谁非要将2560×...

2025-06-24