To eliminate the exponential explosion, one could burn a new keyword. I dunno, call it @applicable
.
- You could not use this approach for any function declared with more than one undefaulted argument.
- For any
f(...) -> T
, where the number of undefaulted arguments is one, would use use the undefaulted argument as $0. For example:func print(_ items: Any..., separator: String = default, terminator: String = default)
, $0 would correspond toitems
, allowing you to passprint
instead of{ print($0) }
- For any
f(...) -> T
with all defaulted arguments, you could decorate precisely one argument with the keyword, for example:g(a: U = _x_, b: @applicable V = _y_) -> T
, $0 would correspond tob
, allowing you to passg
instead of{ g(b: $0) }