Sunday, 29 September 2013

Splicing together symbols with Scala macros

Splicing together symbols with Scala macros

I am trying to call a specialized collections library like FastUtil or
Trove from generic Scala code. I would like to implement something like
def openHashMap[@specialized K, @specialized V]: ${K}2${V}OpenHashMap =
new ${K}2${V}OpenHashMap()
Where the $(X} is just my notation for text substitution like shells, so
that openHashMap[Long, Double] would return a Long2DoubleOpenHashMap the
type would be known at compile time. Is this possible with Scala macros.
If so, which flavour? I know there are def macros, implicit macros, fundep
materialization, macro annotations, type macros (now discontinued) ... and
I think these are different in plain Scala-2.10, 2.10 macro paradise and
Scala-2.11. Which, if any, of these are appropriate for this?

No comments:

Post a Comment