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

2025-06-22 05:10:10

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

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
相关阅读
我国的军工能力可以实现一天5000枚火箭弹连着炸三个月吗?

我国的军工能力可以实现一天5000枚火箭弹连着炸三个月吗?

刚开始看,还以为五千万枚,,,,对不起啊。 。 。 。 我不...

2025-06-26
有哪些值得推荐的 Rust 应用案例?

有哪些值得推荐的 Rust 应用案例?

本文从零开始,通过多版本迭代,实现一个安全的 Rust on...

2025-06-26
35岁以上的人都去做什么工作了呢?

35岁以上的人都去做什么工作了呢?

我曾经在我的回答里介绍过一些野路子程序员,没想到火了,很多人...

2025-06-26
操作系统能否知道自己处于虚拟机中?

操作系统能否知道自己处于虚拟机中?

目前虚拟机环境检测有两个“金标准”,分别是 Al-khase...

2025-06-26
小区楼下的自动售水机的水干净吗?

小区楼下的自动售水机的水干净吗?

说实话,别在小区楼下售水机里打水喝了,我喝了半月,发现再不能...

2025-06-26