为什么Go不支持函数和运算的重载

 

Method dispatch is simplified if it doesn't need to do type matching as well.

不需要做类型匹配的方法处理是简单的。

Experience with other languages told us that having a variety of methods with the same name but different signatures was occasionally useful but that it could also be confusing and fragile in practice.

其他语言的经验告诉我们,函数名称相同,而参数不同,这种使用场景只是偶尔。但是在实践中,重载的应用是很容易令人困惑。

Matching only by name and requiring consistency in the types was a major simplifying decision in Go's type system.

在Go语言里面,函数名称的唯一性规定是为了让程序看起来简洁明了。

Regarding operator overloading, it seems more a convenience than an absolute requirement. Again, things are simpler without it.

关于运算的重载,它也不是必须不可的。同上,没有运算符的重载,程序看起来更简洁明了。

转载于:https://my.oschina.net/jinheking/blog/682363

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值