Scala 清单有哪些限制?
Scala 的 Manifest
是一种解决由于 JVM 缺乏具体化泛型而导致的某些类型擦除问题的方法。
它们在其他几个问题中进行了讨论;这里有一些:
- 什么是Scala 中的清单以及何时需要它?
- Scala 的 ( 2.8)清单工作?
- 如何解决 Scala 上的类型擦除问题?或者,为什么我无法获取集合的类型参数?
- 如何使用 Scala 的 Manifest 类在运行时实例化擦除的类?
- Manifest 与 ClassManifest。这个 Scala 错误是什么意思?
其中一条评论提到“此功能是实验性的,在某些情况下它不起作用。尽管如此,它仍然可以走很长的路。” (Daniel Sobral)
Manifest 方法在哪些情况下会失效?为什么?
Scala's Manifest
s are a way to get around some type erasure problems due to the JVM's lack of reified generics.
They are discussed in several other questions; here are a few:
- What is a Manifest in Scala and when do you need it?
- How does Scala's (2.8) Manifest work?
- How do I get around type erasure on Scala? Or, why can't I get the type parameter of my collections?
- How can I use Scala's Manifest class to instantiate the erased class at runtime?
- Manifest vs ClassManifest. What does this Scala error mean?
One of the comments mentions that “This feature is experimental, and there are cases in which it doesn't work. Still, it can go a long way.” (Daniel Sobral)
What are the cases where the Manifest approach breaks down and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最重要的案例应该是 Scala 团队错误跟踪系统中的开放票证。我发现以下内容:
我相信总体思路是,清单将成为计划/即将推出的 Scala 反射库的一部分,并且除了使用它们之外在数组的上下文中,“风险自负”(参见)。
The most important case should be open Tickets in the Scala teams bug tracking system. I found the following:
I believe the general idea is, that Manifests will be part of the planned/upcomming Scala reflection library and apart from using them in the context of Arrays is "on your own risk" ( see ).
还有一件事:
根据此,清单已弃用2.10 所以他们没有用它们修复错误。
One more:
I've not even reported it since, according to this, manifests are deprecated in 2.10 so they are not fixing bugs with them.