has there ever been a proposal around deferring to...
# language-proposals
has there ever been a proposal around deferring to default values for named params? Use case being that there's cases where you may or may not have a value for a named param, but don't want to write out every possible permutation for function/constructor invocations to allow default values to run
Copy code
data class Foo(val bar: String, val baz: String = "baz")

// somewhere later
val bazValue = getBazValue() ?: Unset
  bar = "bar",
  baz = bazValue
(name could be something better) could be a marker to indicate that you want to defer to the default value. Similar to
. Then you could denote that a value is undefined and basically pretend the argument was never set
This seems similar to Kotlin/JS's use of
. I bet this wouldn't be too much of a challenge. I love this idea
possibly! I'm particularly interested in the context of code gen, where you might generate code that at runtime might not have every argument and you want to say that's ok. Like generating json adapters for data classes and keys that aren't present in the json but you have default values for in the constructor
Great idea, I think this is necessary