28

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:

3
  • This is interesting stuff but more of a mailing list question in its current formulation. At the very least add some links to what you've been reading. May 9, 2012 at 11:27
  • This is my first question ever in StackOverflow, so can you tell me why do you think is not suitable in this context? May 9, 2012 at 13:06
  • I have added the references. Thank you! May 9, 2012 at 13:06

1 Answer 1

23

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. :-)

5
  • I think that's a good way to see it. May 10, 2012 at 6:41
  • This explanation made a lot more sense after understanding Manifests.
    – Grogs
    Nov 13, 2012 at 22:15
  • Actually, it's worse than that. Manifest is not even an exponential functor. This has pretty serious implications for APIs that use it, to the extent that it should never be used. Jan 3, 2013 at 8:05
  • 1
    @TonyMorris - What's the consequence of Manifest's not being an exponential functor? I admit that I don't even know what that is. thanks Feb 20, 2015 at 21:07
  • 1
    @KevinMeredith My guess is that it means that Manifests can't represent all types for any given type parameters.
    – Rag
    May 23, 2015 at 1:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.