you could hide the `version` variable like so:

~~~ scala
val nextVersion = {
  var version = 0L
  () => {
    val current = System.currentTimeMillis
    version = if (current > version) current else version + 1
    version
  }
}
~~~