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

2025-06-23 17:20:14

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

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
相关阅读
你的亲戚提过什么过分的要求?

你的亲戚提过什么过分的要求?

24年末,我花了几千配了一台台式电脑主机,因为原来的那台已经...

2025-06-27
J***a 除了 Spring 还有什么?

J***a 除了 Spring 还有什么?

J***a能做的事还挺多。 著名的沙盒游戏《我的世界》,J...

2025-06-27
NBA 选秀大会杨瀚森首轮第 16 顺位被开拓者选中,他的实力能在开拓者队进入轮换吗?发展前景怎么样?

NBA 选秀大会杨瀚森首轮第 16 顺位被开拓者选中,他的实力能在开拓者队进入轮换吗?发展前景怎么样?

16位,杨瀚森,波特兰开拓者! 有许多可能,但也并不容易。 ...

2025-06-27
为什么现在的年轻人更容易觉得疲惫?

为什么现在的年轻人更容易觉得疲惫?

因为没有精气神。 我爸以前是国营单位的伐木工。 这工作累...

2025-06-27
81年女,本科,未婚未育,还有结婚的可能性吗?

81年女,本科,未婚未育,还有结婚的可能性吗?

没有。 你还没活明白。 婚介公司上班n年的红娘,来分析一下...

2025-06-27