3 ms·
I am not even sure if its a general pattern (inject any dependency?) or a specific pattern they added to Zig
by danieltanfh95 6mo ago
I am not even sure if its a general pattern (inject any dependency?) or a specific pattern they added to Zig
- dnautics 6mo agoidk in elixir we basically do exactly whats happening with io parameters when mocking or swapping implementations that all satisfy the same behaviour. here. i am not the only one that refers to it as dependency injection: https://daily.dev/blog/zig-async-io-io-uring-zig-0-16-rethinks-concurrent-programming#how-zigs-stdio-abstraction-works https://daily.dev/blog/zig-async-io-io-uring-zig-0-16-rethin... "Zig 0.16 introduces std.Io, a flexible I/O abstraction that uses dependency injection, similar to the Allocator interface"
- danieltanfh95 6mo agoSigh. I meant that the zig authors did not make it a general pattern and just slapped on the DI pattern specifically for io, instead of generalising the abstraction so people can DI stuff.
- dnautics 6mo agoit's a general pattern. Allocators use the exact sane vtable mechanism. It's not like first class or anything, but that's fine: its enough of a pain in the ass to set it up that you dont start doing BeanFactoryFactory everywhere