The newest version of Scala, 2.10, will allow to user to execute code at compile time with Macros, which are just normal Scala functions. You can get an overview of the possibilities at the official [cached]Scala Macro guide. Right now, Scala 2.10 is still under development, so you will have to use a Release Candidate to follow along.
First of all, a good system of measurements should make it easy to define values with units in code - no complicated trickery should be required. That's easy to achieve with a small utility macro:
1 |
|