Scala: functions as objects