大部分语言都用尖括号<>表示泛型,为什么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
相关阅读
为什么感觉腾讯的风评越来越好了?

为什么感觉腾讯的风评越来越好了?

20年蛋壳公寓暴雷,所有住户被赶出了租房,腾讯的微众银行要求...

2025-06-21
如何评价中国电科研发的JY-10防空指挥控制系统成为伊朗防空指挥系统核心?

如何评价中国电科研发的JY-10防空指挥控制系统成为伊朗防空指挥系统核心?

看到有答主 @阿槇二号机 称2024年就曾经考证过,JY-1...

2025-06-21
可以用duckdb在本地建立一个数据库对外服务吗?

可以用duckdb在本地建立一个数据库对外服务吗?

Duckdb是一个年轻而迷人的数据库。 它的备份可以简单到通...

2025-06-21
雷军为什么不愿意用性价比打法进军NAS?

雷军为什么不愿意用性价比打法进军NAS?

因为玩nas的真懂技术,小白占比无限接近0%. 其实品牌na...

2025-06-21
为什么 macOS 并不差,可市场总敌不过 Windows?

为什么 macOS 并不差,可市场总敌不过 Windows?

如果你还用OSX系统,哪怕只是9年前的版本,市面上也几乎没有...

2025-06-21