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

2025-06-22 14:45: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
相关阅读
为什么 mac mini 的 m4 版本价格这么低呢?

为什么 mac mini 的 m4 版本价格这么低呢?

就是卖不动了,只好一轮一轮的降价。 和现在的房子一样,当然它...

2025-06-27
最适合 Mac 带 Type-C 接口的转接口 / 扩展坞有哪些?

最适合 Mac 带 Type-C 接口的转接口 / 扩展坞有哪些?

Mac mini M4必入的桌面搭子!零刻Mate mini...

2025-06-27
如何看待美团创始人王兴清空微博?

如何看待美团创始人王兴清空微博?

昨天走街串巷看到一个襄阳牛肉面,顺便有热干面,闻着味就知道绝...

2025-06-27
为什么健身的女性普遍喜欢晒臀照?什么心理?

为什么健身的女性普遍喜欢晒臀照?什么心理?

我真的很想说 我在健身房混迹大半年了 脱了裤子,无论是基因还...

2025-06-27
J***aScript 已经强大到什么程度了?

J***aScript 已经强大到什么程度了?

今天,我们来聊聊一个可能被你忽视,而且非常强大的标准 J**...

2025-06-27