[swift-evolution] [Review] SE-0047 Defaulting non-Void functions so they warn on unused results
Maximilian Hünenberger
m.huenenberger at me.com
Sun Mar 27 08:33:14 CDT 2016
In the proposal there is no mention of generic functions.
Take a map function of a Wrapper:
Wrapper<T> {
func map<U>(transform: T -> U) -> U { ... }
}
let intWrapper = Wrapper(1)
intWrapper.map{ print($0) } // this returns Void
Should the last line be inferred to have a discardable result?
In my opinion a function which returns a generic result should warn for unused results in every case. Here, "map" gets a closure with side effects which is very unusual and should be handled with another function like "apply".
- Maximilian
More information about the swift-evolution
mailing list