# HG changeset patch # User wenzelm # Date 1521109652 -3600 # Node ID 449ed1afa05668933dd9cac799a3793cc031e924 # Parent 1805960b4a9fa71cf89d6b53b0f4eea088da2930 prefer non-strict defaults; diff -r 1805960b4a9f -r 449ed1afa056 src/Pure/General/json.scala --- a/src/Pure/General/json.scala Thu Mar 15 11:20:17 2018 +0100 +++ b/src/Pure/General/json.scala Thu Mar 15 11:27:32 2018 +0100 @@ -325,7 +325,7 @@ case _ => None } - def value_default[A](obj: T, name: String, unapply: T => Option[A], default: A): Option[A] = + def value_default[A](obj: T, name: String, unapply: T => Option[A], default: => A): Option[A] = value(obj, name) match { case None => Some(default) case Some(json) => unapply(json) @@ -333,31 +333,31 @@ def string(obj: T, name: String): Option[String] = value(obj, name, Value.String.unapply) - def string_default(obj: T, name: String, default: String = ""): Option[String] = + def string_default(obj: T, name: String, default: => String = ""): Option[String] = value_default(obj, name, Value.String.unapply, default) def double(obj: T, name: String): Option[Double] = value(obj, name, Value.Double.unapply) - def double_default(obj: T, name: String, default: Double = 0.0): Option[Double] = + def double_default(obj: T, name: String, default: => Double = 0.0): Option[Double] = value_default(obj, name, Value.Double.unapply, default) def long(obj: T, name: String): Option[Long] = value(obj, name, Value.Long.unapply) - def long_default(obj: T, name: String, default: Long = 0): Option[Long] = + def long_default(obj: T, name: String, default: => Long = 0): Option[Long] = value_default(obj, name, Value.Long.unapply, default) def int(obj: T, name: String): Option[Int] = value(obj, name, Value.Int.unapply) - def int_default(obj: T, name: String, default: Int = 0): Option[Int] = + def int_default(obj: T, name: String, default: => Int = 0): Option[Int] = value_default(obj, name, Value.Int.unapply, default) def bool(obj: T, name: String): Option[Boolean] = value(obj, name, Value.Boolean.unapply) - def bool_default(obj: T, name: String, default: Boolean = false): Option[Boolean] = + def bool_default(obj: T, name: String, default: => Boolean = false): Option[Boolean] = value_default(obj, name, Value.Boolean.unapply, default) def list[A](obj: T, name: String, unapply: T => Option[A]): Option[List[A]] = value(obj, name, Value.List.unapply(_, unapply)) - def list_default[A](obj: T, name: String, unapply: T => Option[A], default: List[A] = Nil) + def list_default[A](obj: T, name: String, unapply: T => Option[A], default: => List[A] = Nil) : Option[List[A]] = value_default(obj, name, Value.List.unapply(_, unapply), default) }