PHP 7.1是否支持操作符重载?
2016-02-24 00:00
537 查看
目前还只是一个提议。
新闻来源:http://www.phpclasses.org/blog/post/350-Operator-Overloading-in-PHP-71--Lately-in-PHP-podcast-episode-68.html
以下是原文内容:
Operator overloading is a feature being proposed for PHP 7.1 that will allow using regular operators, like +, -, *, /, to perform operations with class objects using new magic methods. That was one of the main topics discussed by Manuel Lemos and Arturs Sosins in the episode 68 of the Lately in PHP podcast hangout.
They also talked about better handling of bugs caused by using invalid string values in arithmetic operations, supporting negative string offsets in all string operations, and better handling of issues caused by the regeneration of session IDs.
They also talked about the recent victory of Dave Smith and the United States team in the PHP Innovation Award, as well the improvements to the PHP Classes site features for promoting contributing authors work suggested by these winning authors.
Listen to the podcast, or watch the hangout video to learn more about these interesting PHP topics.
原文地址下面有讨论的视频和录音,当然你得看得到才行。
嗯,在Scala体验过操作符重载,其实际编程意义并不大,obj->add(x)或obj->plus(x)和obj + x,其实我可能会更喜欢前者。毕竟PHP还不是彻底的面向对象,引用的问题虽然在PHP7已经有重大的改进 ,但对于对象的引用仍然可能引发很多不可知的bug。此时加入操作重载,会不会带来一些灾难呢?实际上PHP 7.0.3的此刻,仍有很多未被close的bugs,还是谨慎点比较好吧(今天貌似发现了array_object的另一个bug....)。
呃,貌似在视频里听到提到了Scala,我想说的是Scala有很多东西也不完全是好。
我还是希望PHP能保持某种语言层面上的纯粹性,C#已经惨不忍睹了,Js也被node.js玩坏了。
最后,补发一下php的rfc:https://wiki.php.net/rfc。
新闻来源:http://www.phpclasses.org/blog/post/350-Operator-Overloading-in-PHP-71--Lately-in-PHP-podcast-episode-68.html
以下是原文内容:
Operator overloading is a feature being proposed for PHP 7.1 that will allow using regular operators, like +, -, *, /, to perform operations with class objects using new magic methods. That was one of the main topics discussed by Manuel Lemos and Arturs Sosins in the episode 68 of the Lately in PHP podcast hangout.
They also talked about better handling of bugs caused by using invalid string values in arithmetic operations, supporting negative string offsets in all string operations, and better handling of issues caused by the regeneration of session IDs.
They also talked about the recent victory of Dave Smith and the United States team in the PHP Innovation Award, as well the improvements to the PHP Classes site features for promoting contributing authors work suggested by these winning authors.
Listen to the podcast, or watch the hangout video to learn more about these interesting PHP topics.
原文地址下面有讨论的视频和录音,当然你得看得到才行。
嗯,在Scala体验过操作符重载,其实际编程意义并不大,obj->add(x)或obj->plus(x)和obj + x,其实我可能会更喜欢前者。毕竟PHP还不是彻底的面向对象,引用的问题虽然在PHP7已经有重大的改进 ,但对于对象的引用仍然可能引发很多不可知的bug。此时加入操作重载,会不会带来一些灾难呢?实际上PHP 7.0.3的此刻,仍有很多未被close的bugs,还是谨慎点比较好吧(今天貌似发现了array_object的另一个bug....)。
呃,貌似在视频里听到提到了Scala,我想说的是Scala有很多东西也不完全是好。
我还是希望PHP能保持某种语言层面上的纯粹性,C#已经惨不忍睹了,Js也被node.js玩坏了。
最后,补发一下php的rfc:https://wiki.php.net/rfc。
相关文章推荐
- PHP json_decode返回null解析失败原因
- PHP 使用 header 跳转支付界面,传递不过参数
- PHP实现排序算法
- php分享二十四:数组
- PHP利用可变函数动态扩增类的属性
- PHP字符串的翻转_原生实现
- Yii2.0数据库操作(1)
- Mac 中PHP连接MySQL总是失败localhost修改成127.0.0.1解决
- PHP 简单的小偷程序
- php\symfony3 学习记录(一)创建第一个symfony项目
- ThinkPHP3.2.3 自定义标签库的使用
- PHP 安装包依赖关系管理工具Composer
- php操作mysql数据库
- php分享二十三:字符编码
- 容易混淆的知识点
- thinkphp_3.1.2查询和视图
- yii phpexcel自己主动生成文件保存到server上
- php可变参数
- 独特的php遍历数组的写法,reset(),next(),current()
- 优秀的PHP开源项目集合