Comment by ginko

Comment by ginko a day ago

3 replies

>you can call a function that requires an io parameter from a function that doesn't have one by passing in a global io instance?

How will that work with code mixing different Io implementations? Say a library pulled in uses a global Io instance while the calling code is using another.

I guess this can just be shot down with "don't do that" but it feels like a new kind of pitfall get get into.

throwawaymaths a day ago

> Say a library pulled in uses a global Io instance while the calling code is using another.

it'll probably carry a stigma like using unsafe does.

TUSF a day ago

Zig already has an Allocator interface that gets passed around, and the convention is that libraries don't select an Allocator. Only provide APIs that accept allocators. If there's a certain process that works best with an Arena, then the API may wrap a provided function in an Arena, but not decide on their own underlying allocator for the user.

For Zig users, adopting this same mindset for Io is not really anything new. It's just another parameter that occasionally needs to be passed into an API.

kristoff_it a day ago

while not really idiomatic, as long as you let the user define the Io instance (eg with some kind of init function), then it doesn't really matter how that value is accessed within the library itself.

that's why this isn't really the same as async "coloring"