博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
为什么Go不支持函数和运算的重载
阅读量:7089 次
发布时间:2019-06-28

本文共 723 字,大约阅读时间需要 2 分钟。

hot3.png

 

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

你可能感兴趣的文章
c++ abs与fabs
查看>>
JVM 运行时数据区域
查看>>
数据库扩展
查看>>
WPF自定义控件与样式(9)-树控件TreeView与菜单Menu-ContextMenu
查看>>
Eclipse 调试 Java 程序的技巧
查看>>
Project Euler 95:Amicable chains 亲和数链
查看>>
HTML5调用传感器的资料汇总
查看>>
maven安装配置
查看>>
全民Scheme(0):lat的定义
查看>>
[转]Worksheet.Change Event (Excel)
查看>>
cpu性能探究 :cache line 原理
查看>>
mysql忘记root密码拯救方法(flush privileges)
查看>>
[转载]UML用例图总结
查看>>
LinkedBlockingQueue
查看>>
Lucene.Net+盘古分词器(详细介绍)(转)
查看>>
HDU 4902 Nice boat(线段树)
查看>>
正确理解Python文件读写模式字w+、a+和r+
查看>>
不可不知的DIP、IoC、DI以及IoC容器
查看>>
大漠教程 找字 找图片
查看>>
不同时间复杂度的规模上限
查看>>