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

2025-06-21 23:00:17

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

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
相关阅读
长期使用的大佬来说说,MacOS 真的比 Windows 稳定吗?

长期使用的大佬来说说,MacOS 真的比 Windows 稳定吗?

长期来看,其实Windows系统远比我们想象中的要稳定,30...

2025-06-21
如何看待特朗普第三次宣布延长出售 Tiktok 的时限?美方此举背后有哪些考量?

如何看待特朗普第三次宣布延长出售 Tiktok 的时限?美方此举背后有哪些考量?

典型的「有法不依」。 法律是国会定的,TikTok 符合什么...

2025-06-21
postgres集群的选择?

postgres集群的选择?

我们需要谈谈困扰我几个月的事情。 我一直看到独立黑客和初创公...

2025-06-21
MacOS真的比Windows流畅吗?

MacOS真的比Windows流畅吗?

说实话,我很有发言权。 手上刚买一台13寸MacBook ...

2025-06-21
如何评价《灵笼 2》第六集?

如何评价《灵笼 2》第六集?

马克失魂落魄的这段日子,麦朵小妹妹短暂的温暖过他,但这束阳光...

2025-06-21