How do the new Scala TypeTags improve the (deprecated) Manifests? [duplicate]

我是研究僧i 提交于 2019-12-18 10:41:38

问题


Possible Duplicate:
Scala 2.10: What is a TypeTag and how do I use it?

I have been reading about the new TypeTags which come along with the new reflection api. It seems that Manifests are supposed to be replaced with that new concept. Can anyone post some code examples to show the benefits?

Some references:

  • TypeTags API
  • SIP: Self-cleaning macros
  • Metaprogramming in Scala

回答1:


Manifests are a lie. It has no knowledge of variance (assumes all type parameters are co-variants), and it has no support for path-dependent, existential or structural types.

TypeTags are types as the compiler understands them. Not "like" the compiler understands them, but "as" the compiler understands them -- the compiler itself use TypeTags. It's not 1-to-1, it's just 1. :-)



来源:https://stackoverflow.com/questions/10513336/how-do-the-new-scala-typetags-improve-the-deprecated-manifests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!