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

2025-06-19 08:50:12

最新的设计文档里面对这一块做了一个解释。

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
相关阅读
西方人是怎么发现地球是圆的的?

西方人是怎么发现地球是圆的的?

看了高赞回答,很多人心里完全接受不了,2000多年前的古希腊...

2025-06-20
人类真的想象不出从来没见过的东西吗?

人类真的想象不出从来没见过的东西吗?

近日,河北一男子晚饭后在楼下的小区散步,突然发现一户人家窗口...

2025-06-20
一米二的棍子打的赢三十厘米的刀子吗?

一米二的棍子打的赢三十厘米的刀子吗?

先说结论,打不过。 一米二什么概念?就一扫把棍。 无论是...

2025-06-20
Rust 使用 Result 的错误处理方式与 Golang 使用 error 的方式有什么本质区别?

Rust 使用 Result 的错误处理方式与 Golang 使用 error 的方式有什么本质区别?

rust 的 result 是枚举,只有2个答案,要么ok要...

2025-06-20
你见过最上进的人是怎样的?

你见过最上进的人是怎样的?

以前打csgo,经常因为一直打游戏被某前女朋友说。 有一次...

2025-06-20