3 ms·
Well yeah - you can do exactly the same in other languages, such as Scala. It just isn't a good idea. They explain it themselves: > there’s plenty of applicati
by valenterry 6y ago
Well yeah - you can do exactly the same in other languages, such as Scala. It just isn't a good idea. They explain it themselves:
> there’s plenty of applications that need evented I/O to behave correctly. Switching to blocking mode, without introducing any change, might cause them to deadlock
- dnautics 6y agozig doesn't switch. It's statically typed, and I think (not 100% sure) it detects if you have called a function with the async keyword and when that happens it triggers compiling a second version of the function with async support, so there are actually two versions of the function floating around in your binary. Since zig is itself a parsimonious compiler, if that's never in a codepath (say it's provided by a library), it doesn't get compiled. The reverse is true, too, if you ONLY call a function with the async keyword, it doesn't compile the non-async version. Again, with the caveat that I think that's what's going on.
- dnautics 6y agoCorrection: my understanding is incorrect, zig does not compile two versions of the functions. Nonetheless, it does not switch.
- valenterry 6y agoWell, I'm quoting their own explanation...