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

2025-06-23 00:00: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
相关阅读
你身边身材最好的女生是什么样?

你身边身材最好的女生是什么样?

去游泳的时候见过一个,165左右,小头宽肩细腰胯宽腿直肤白,...

2025-06-18
如何评价字节跳动开源的 Netpoll?

如何评价字节跳动开源的 Netpoll?

0 前言不久前曾经对 golang 原生的 net 网络库(...

2025-06-18
如果战争爆发,中国普通老百姓枪都不会打该怎样自卫?

如果战争爆发,中国普通老百姓枪都不会打该怎样自卫?

这个问题无解 虽然国家禁枪 但国外很多靶场教练发现 从来没见...

2025-06-18
编程语言 MoonBit 发布 Beta 版,正式进入企业场景应用,会带来哪些影响?

编程语言 MoonBit 发布 Beta 版,正式进入企业场景应用,会带来哪些影响?

MoonBit 的 Beta 版发布意味着语法已趋于稳定,接...

2025-06-18
2024 年了,你的科研工具箱更新了哪些新工具?

2024 年了,你的科研工具箱更新了哪些新工具?

今年淘汰掉的科研工具:翻译软件:DeepL, Google ...

2025-06-18