| ▲ | throwawaymaths an hour ago | ||||||||||||||||
1) zig's io is not a viral effect type, you can in principle declare a global io variable and use it everywhere that any library calls for it. Not best practice for a library writer, but if you're building an app, do what you want. 2) There are two things here, there is function coloring and the function coloring problem. The function coloring problem is five things: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-... 1. Every function has a color. 2. The way you call a function depends on its color. 3. You can only call a red function from within another red function. 4. Red functions are more painful to call. 5. Some core library functions are red. You'll have some convincing to do that zig's plan satisfies 4. It's almost certain that it won't satisfy 5. It's open to debate if zig's plan will work at all, of course. | |||||||||||||||||
| ▲ | woodruffw an hour ago | parent [-] | ||||||||||||||||
> 1) zig's io is not an effect type, you can in principle declare a global io variable and use it everywhere that any library calls for it. That's an effect, akin to globally intermediated I/O in a managed runtime. To make it intuitive: if you have a global token for I/O, does your concurrent program need to synchronize on it in order to operate soundly? Do programs that fail to obtain the token behave correctly? | |||||||||||||||||
| |||||||||||||||||