3 ms·
Isn't every function in the world (in non duck-type runtime languages) colored by its return type? Functions have signatures. You can't call a function that ret
by dcow 5y ago
Isn't every function in the world (in non duck-type runtime languages) colored by its return type? Functions have signatures. You can't call a function that returns an int and store the value into a variable of type string. Similarly, you can't store a future<int> to a variable of type int without yielding execution and (a)waiting for the result to show up in some memory location and then copying that.
async/await is just syntax that removes boilerplate from some common patterns like returning a future and yielding execution while waiting on its result. You could implement this yourself in every function, but people don't want to and find async/await convenient. So here we are.
Maybe it's just me, but the whole function color thing really comes off as "why can't I store a string in an int variable? The compiler could call itoa for me why doesn't it?". I mean if that's what you want go use a language where the compiler does that for you. We're here using types because we care about code correctness and are willing to endure some compile time restrictions to achieve it.