问题
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