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

2025-06-23 00:00:13

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

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
相关阅读
苹果从 2026 年发布的 macOS 27 起不再兼容任何 Intel Macs,这背后原因有哪些?

苹果从 2026 年发布的 macOS 27 起不再兼容任何 Intel Macs,这背后原因有哪些?

丸辣,Rosetta2的AVX2支持才刚起步就要被抛弃辣。 ...

2025-06-26
你的低成本爱好是什么?

你的低成本爱好是什么?

送外卖。 每次只接两三单,不怕超时,开着音乐慢慢悠悠地送,...

2025-06-26
现在既然全靠雷达了,为啥伊以炸来炸去都要在晚上?

现在既然全靠雷达了,为啥伊以炸来炸去都要在晚上?

主要是为了降低卫星发现液体导弹的加注和发射准备的概率。 虽...

2025-06-26
为什么Next.js和Nuxt.js发布时间只隔了几小时?

为什么Next.js和Nuxt.js发布时间只隔了几小时?

2016年10月25日,Vercel 公司首次在 GitHu...

2025-06-26
rust在国内的前景如何?

rust在国内的前景如何?

1,找工作肯定很难找,或者说除一线城市外,几乎没有。 一线也...

2025-06-26