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

2025-06-21 21:55:11

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

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
相关阅读
如何阅读Golang的源码?

如何阅读Golang的源码?

有些库并不值得看,比如archive、compress以及c...

2025-06-25
如何评价B站up主***千代退网?

如何评价B站up主***千代退网?

你们说的就是这个人吗? 这种***姬早些年主战场都是在微...

2025-06-25
山姆超市是怎么在中国火起来的?

山姆超市是怎么在中国火起来的?

一直在山姆极速达买西瓜,有一次送来的西瓜切开感觉有点不好,不...

2025-06-25
整数经纬度的交汇点周围都有什么呢?

整数经纬度的交汇点周围都有什么呢?

看了一下 ***://confluence.org 这个网站...

2025-06-25
现在已经有5K、6K、8K分辨率显示器,那么8K之后是什么?

现在已经有5K、6K、8K分辨率显示器,那么8K之后是什么?

8K之后是16K,但个人认为16K可能遥遥无期,毕竟8K都还...

2025-06-25