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

2025-06-22 04:05: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
相关阅读
为什么都认为无GC语言一定会比有GC语言要快?

为什么都认为无GC语言一定会比有GC语言要快?

我们产品一个go实现的后台,高并发大流量时cpu十分繁忙,g...

2025-06-23
最好的笔记软件是什么?

最好的笔记软件是什么?

目前来说(2025年6月),上个月Google新出的Note...

2025-06-23
养乌龟是什么体会?

养乌龟是什么体会?

大水体深水养乌龟的忠实信徒。 条件不允许,只有25厘米的水深...

2025-06-23
C盘为什么无法扩容?

C盘为什么无法扩容?

需要用特殊工具才可以,推荐DiskGenius。 但该操作...

2025-06-23
哪些音频剪辑工具很好用?

哪些音频剪辑工具很好用?

现在短***太火啦,谁还不会点剪辑,那大家剪辑过背景音乐没?...

2025-06-23