限制隐式参数和视图/上下文边界组合的原因是什么?
最近对 Scala master 的提交之一消除了对上下文/视图边界与隐式参数。这是一个很大的改进,减少了样板文件的数量,但是之前做出这种限制的原因是什么,现在我们可以预期什么后果?
One of the recent commits to Scala master removes restriction on combining context/view bounds with implicit parameters. That's a great improvement that reduces amount of boilerplate, but what was the reason of making that restriction before, and what consequences can we expect now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上下文和视图边界添加隐式参数。因此,如果您这样写:
事实上,传递的是两个 隐式参数,而不是一个。允许这种语法肯定会导致一些混乱。由于类型类的存在,隐式参数的使用开始变得更加广泛,能够执行上述操作会很有帮助。
Context and view bounds add implicit parameters. So if you write:
There are, in fact, two implicit parameters being passed instead of one. Allowing this kind of syntax will certainly result in some confusion down the road. As implicit parameter usage starts to get more widespread, because of type classes, being able to do something like the above is helpful.