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

2025-06-23 10:20: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
相关阅读
哪个瞬间让你觉得编程只是一门技术?

哪个瞬间让你觉得编程只是一门技术?

当年做游戏开发,C++、Lua、J***aScript、Ty...

2025-06-25
golang为什么要内置map?

golang为什么要内置map?

学太多的坏处就想太多。 Go 从一开始就不是一个想很多的语...

2025-06-25
突然停电,对电脑伤害大吗?

突然停电,对电脑伤害大吗?

台式机电源,有一个参数叫“保持时间”。 而根据英特尔ATX3...

2025-06-25
穿了瑜伽裤真的舒服吗?

穿了瑜伽裤真的舒服吗?

恕我见识短浅,我是通过女生才知道还有***屁股和***三角区...

2025-06-25
怎么看待B站舞蹈区和某些风格比较暴露的up?

怎么看待B站舞蹈区和某些风格比较暴露的up?

不是,都没有兄弟提朱姨、还有糕哥枣糕DAZE、ParmyAu...

2025-06-25