你现在的位置是:当前位置: 首页 >


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

更新时间:2025-06-18 16:10: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要标新立异用中括号?

案例推荐

case recommendation
  • 马斯克宣布星舰将配备 42 台发动机,如何评价这一设计?

    查看案例

  • 为什么go语言gc的时候要暂停整个程序?

    查看案例

  • 如何看待《剑星》已登顶 Steam 全球热销榜?

    查看案例

  • 巴基斯坦援助伊朗防空,大家怎么看?

    查看案例

  • 软件api接口为什么导入不了ip?

    查看案例

  • 打过生长激素是什么体验?

    查看案例

  • 5060会不会很容易爆显存?

    查看案例

  • 如何看待伊朗国家电视台发文:“今晚,将会发生一件大事,让世界铭记几个世纪。”?

    查看案例