> Am 12.09.2017 um 21:18 schrieb Adam Kemp <[email protected]>:
> 
>> On Sep 11, 2017, at 9:56 PM, Thorsten Seitz <[email protected]> wrote:
>> 
>> My hope would be for something along these lines:
>> 
>> func createDownloadTasks(for urls: [URL]) -> [async Data] {
>>   return urls.map { url in async downloadResource(url) }
>> }
>> func await(all tasks: [async Data]) async -> [Data] {
>>   return tasks.map { task in await task }
>> }
> 
> So that’s basically a new type with a special syntax. What is the advantage 
> to doing it that way versus just introducing a new protocol?

Just syntactic sugar (like `?` for Optionals) which happens to align with the 
async/await syntax. But you are right, the syntactic sugar should represent a 
type which can be represented in the language. Syntactic sugar probably only 
makes sense if it stands for a fixed concrete type (like Optional) which is 
probably a bad idea compared to C# where we can customize the concrete task 
type. It just has to have a GetAwaiter method.

So there is no need for such syntactic sugar and it even is a hindrance.

-Thorsten
 
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to