Thinking about it, wouldn't hiding the implementation of Future<T> have the
advantage of preventing people from returning Futures from functions ?
This would allow to write this:
func foo() async -> Future<SomeType> {
let futureValue = Future { await someOtherFunc() }
doSomethingElse()
return futureValue
}
As this:
func foo() async -> SomeType {
let futureValue = async someOtherFunc()
doSomethingElse()
return futureValue
}
Internally compiler would add an await at return:
func foo() async -> SomeType {
let futureValue = async someOtherFunc()
doSomethingElse()
return await futureValue
}
With this syntax it would seem useless to return Future from a function !
Wouldn't it also avoid to skip some thread safety checks that would be required
by Future being publicly implemented as a class ?
What do you think about it ?_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution