| ▲ | jakelazaroff 6 hours ago | |||||||||||||||||||||||||||||||||||||||||||
In Zig's case you pass the argument whether or not it's asynchronous, though. The caller controls the behavior, not the function being called. | ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | layer8 5 hours ago | parent [-] | |||||||||||||||||||||||||||||||||||||||||||
The coloring is not the concrete argument (Io implementation) that is passed, but whether the function has an Io parameter in the first place. Whether the implementation of a function performs IO is in principle an implementation detail that can change in the future. A function that doesn't take an Io argument but wants to call another function that requires an Io argument can't. So you end up adding Io parameters just in case, and in turn require all callers to do the same. This is very much like function coloring. In a language with objects or closures (which Zig doesn't have first-class support for), one flexibility benefit of the Io object approach is that you can move it to object/closure creation and keep the function/method signature free from it. Still, you have to pass it somewhere. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||