我们应该直接使用 ScalaSignature 吗? [英] Should we use the ScalaSignature directly?
问题描述
ScalaSignature 是一个注解.它包含元信息.
The ScalaSignature is an annotation. It contains meta informations.
然后提供解析器.但是 scala-library.jar
不包含解析器.看起来像是秘密 API.
And then parser is provided. but scala-library.jar
is not contains the parser. It seem like secret API.
但我知道一些使用 ScalaSignature 的库.
But I know a few libraries using ScalaSignature.
- https://github.com/lift/framework/blob/2.4-release/core/json/src/main/scala/net/liftweb/json/ScalaSig.scala
- https:///github.com/msgpack/msgpack-scala/blob/version-0.6.6/src/main/scala/org/msgpack/scalautil/ScalaSigUtil.scala
- https://github.com/havocp/beaucatcher/blob/v0.5.0/caseclass/src/main/scala/org/beaucatcher/caseclass/ClassAnalysis.scala
顺便说一下,我找不到 ScalaSignature 的正式规范.我担心 ScalaSignature 的规范可能会因 Scala 版本的变化而改变.此外,我认为使用 ScalaSignature 还存在一些其他风险,因为规范不存在.
By the way, I could not found formal specification of ScalaSignature. I worry that the specification of ScalaSignature may change by a Scala version change. Also I think there are some other risks using ScalaSignature because specification doesn't exists.
此外,Scala2.10 将提供一个新的反射 API.2.10 发布后,我认为使用 ScalaSignature 的原因会减少.
Further, Scala2.10 will provide a new reflection API. I think the reason for using ScalaSignature will decrease, when 2.10 is released.
因此,应该使用 ScalaSignature 吗?
Thus, should one use the ScalaSignature?
推荐答案
Scala 2.10 中的反射 API 提供了官方支持的对 Java 反射 + Scala 签名的抽象.如果 ScalaSignature 格式改变,反射也会相应改变.
Reflection API in Scala 2.10 provides an officially supported abstraction over Java reflection + Scala signatures. If ScalaSignature format changes, reflection will change accordingly.
这篇关于我们应该直接使用 ScalaSignature 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!