async / await

Imperatorn johan_forsberg_86 at hotmail.com
Fri Oct 8 07:29:11 UTC 2021


On Friday, 8 October 2021 at 06:38:17 UTC, bauss wrote:
> On Thursday, 7 October 2021 at 23:20:15 UTC, Imperatorn wrote:
>> On Thursday, 7 October 2021 at 22:35:23 UTC, russhy wrote:
>>> I don't think trying to replicate C# async/await is a good 
>>> idea, it promotes creating bad APIs (GetThisAsync | 
>>> GetThisAsync.ButSyncThisTimeToGetResult)
>>>
>>> https://kristoff.it/blog/zig-colorblind-async-await/
>>>
>>> Zig's approach is cleaner imo
>>
>> I think you misunderstood me. What I meant was just the 
>> async/await keywords
>
> No, he understood you and is talking about the method 
> implementations in C#.
>
> But tbh. the solution is to provide both an asynchronous and a 
> synchronous version of the method.
>
> Ex.
>
> DownloadFile() would be synchronous, whereas 
> DownloadFileAsync() would then be async.
>
> That avoids the whole problem of calling an async method 
> synchronous, because in general you shouldn't ever do that 
> anyway!

But, I wasn't talking about the implementation. I just used C# as 
an example rather than for example Zig.

The keywords are separate from the implementation. The same way 
that if we didn't have foreach as a keyword and decided to 
introduce it.

I was mainly talking about the purely syntactic aspect of the 
source code.

It would (also) make the porting of Zig/[insert language here] to 
D easier.


More information about the Digitalmars-d mailing list