Tag: scala

Units of Measure - A Scala Macro System

I finally finished my Units of Measure system for Scala. The source is - of course - on GitHubcache, and I'm putting the finishing touches on my thesis about it, but for a quick view please refer to this presentation:


Units of Measurement - An Overview

Last time, I talked a bit about how you might implement parts of a Units of Measurement system in Scala (stay tuned for the rest of the implementation). Since this is going to be the topic of my Bachelor's thesis, I've made a presentation about Units of Measurement systems in other languages, specifically F#, C++ and Haskell. You can view it right here:

or download a pdf (without the snazzy transitions).


A System of Measurements in Scala

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 Scala Macro guidecache. 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:

val a = u(42, "m …

© Julian Schrittwieser. Built using Pelican. Theme by Giulio Fidente on github. .