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

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

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

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

2025-06-23
你在你男/女朋友的手机里发现过什么秘密?

你在你男/女朋友的手机里发现过什么秘密?

不是男朋友,是老公。 我老公快30岁了,但是心智不成熟,像...

2025-06-23
SwiftUI 是不是一个败笔?

SwiftUI 是不是一个败笔?

概览小伙伴们都知道,为了将 SwiftUI 中多如牛毛的视图...

2025-06-23
国内大厂现在用rust的多吗?

国内大厂现在用rust的多吗?

RUST在linux内核中持续了好几年,不断有特性合入lin...

2025-06-23
国产厂商为什么都不用三星屏幕了?

国产厂商为什么都不用三星屏幕了?

大家还记得当年某品牌的老板为了获得三星的屏幕供应,上门跪求三...

2025-06-23