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

Views :
Update time : 2025-06-19 22:45: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要标新立异用中括号?
Related News
Read More >>
Blog Post With Youtube Video 有哪些动物看上去比较弱,没有毒,也不是没肉可吃,但食肉动物一般不吃它?
2025-06-24 05:50:10
有哪些动物看上去比较弱,没有毒,也不是没肉可吃,但食肉动物一般不吃它?...
Blog Post With Youtube Video 自己有车位,但是没有车,就想把对象的车停进去,结果物业不允许,这合法吗?
2025-06-24 06:35:10
自己有车位,但是没有车,就想把对象的车停进去,结果物业不允许,这合法吗?...
Blog Post With Youtube Video 为什么都认为无GC语言一定会比有GC语言要快?
2025-06-24 06:35:10
为什么都认为无GC语言一定会比有GC语言要快?...
Blog Post With Youtube Video Golang与Rust哪个语言会是今后的主流?
2025-06-24 06:05:10
Golang与Rust哪个语言会是今后的主流?...

Leave Your Message