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

2025-06-25 13: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
相关阅读
中年夫妻有多少是生活和谐的?

中年夫妻有多少是生活和谐的?

可能我俩还不到中年。 。 。 我三十我老公二十八。 之前在...

2025-06-20
Python+rust会是一个强大的组合吗?

Python+rust会是一个强大的组合吗?

不不不,把python去掉,只用rust。 组合个毛线啊,...

2025-06-20
为什么上海暂时还没取代香港成为亚洲金融中心?还没取代纽约成为世界金融中心?

为什么上海暂时还没取代香港成为亚洲金融中心?还没取代纽约成为世界金融中心?

一个***想开起来,需要四个因素: 1-允许赚钱的人***,...

2025-06-20
不结婚,不生孩子,老了怎么办?

不结婚,不生孩子,老了怎么办?

日本有个叫“终活”的说法: 60岁时,把自己的所有金融财产,...

2025-06-20
工业克苏鲁什么意思?

工业克苏鲁什么意思?

22年初,大年初五给闺女买了两只小乌龟,中华草龟,送了个养龟...

2025-06-20