Viewing old version 13f24f1d497a8053c1f86453b851c461530397a7; View Current
This isn’t covered by the tour.
Type Specialization is a feature that allows the Scala compiler to create type-specific versions of classes that take type parameters. For example, if you have a collection of type
Collection[T], and you specialize
T, the compiler will create not just one class, but one for each primitive type as well as for the object type.
This is entirely transparent to the programmer, and essentially is useful for optimizing code that is being slowed down by autoboxing.
Note that the more type parameters you specialize, the more specialized classes are created, because each combination of primitives must be created to full specialize.
For a great overview, watch this talk from ScalaDays 2010
My Thoughts on This Feature
On one hand, this seems like a hyper-optimization that you should rarely really need. On the other hand, I can’t see a reason not to always do this, so why is it a feature at all? I suspect this is only useful for API writers who need to squeeze every ounce of performance out of their code.
Last Updated 07/16/2010 at 01:54:06 PM by davecblog comments powered by Disqus
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.