简体   繁体   English

限制组合隐式参数和视图/上下文范围的原因是什么?

[英]What was the reason to restrict on combining implicit parameters and view/context bounds?

One of the recent commits to Scala master removes restriction on combining context/view bounds with implicit parameters. 对Scala master 的最新提交之一消除了将上下文/视图边界与隐式参数结合的限制。 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? 这是一个很大的改进,减少了样板数量,但是之前进行此限制的原因是什么,我们现在可以期待什么后果?

Context and view bounds add implicit parameters. 上下文和视图范围添加隐式参数。 So if you write: 因此,如果您写:

def f[T : Manifest](l: List[T])(implicit ord: Ordering[T]) 

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. 由于类型类的原因,隐式参数的使用开始变得越来越普遍,因此能够执行上述操作将很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM