[swift-evolution] Disambiguate Return Type With Void
Антон Жилин
antonyzhilin at gmail.com
Tue Apr 26 08:57:30 CDT 2016
+1
> Also, technically we can assign a value to Void function
This proposal will not disallow that. Just non-Void functions will be
preferred when result is used.
array.sort(..) // mutating
let array2 = array.sort(..) // non-mutating, instead of array.sorted()
I think, that's actually the best solution to mutating / non-mutating
convention!
Andrew, why not generalize this proposal to functions with @unusedResult?
In terms of "precedence" when result is used:
Non-Void > @unusedResult > Void (+warning)
When unused:
Void > @unusedResult > Non-Void (+warning)
- Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160426/966c7ba5/attachment.html>
More information about the swift-evolution
mailing list