Re:Don't Forget to Flush by Andrew Kelley [video]
by ozgrakkurt on Monday August 11, 2025 @07:28PM
(#44870637)
Afaik the new recommended pattern is to have “unmanaged” apis so structs don’t keep allocators inside but take it in every function call.
Passing an extra argument for allocator is fine in my experience, it doesn’t really take much time to write it down and it is nice to be able to see if a function does allocation from it’s signature alone
I think Odin went with implicit context system[1], making some state accessible across function boundaries, but it seems to be against Zig's philosophy on explicit control flow.
In practice it might end up being not a big deal, especially considering that both allocator and io can be shoved into struct's fields:
Props to Andrew for going against the grain and making unorthodox decisions - the only way to get out of the local minimum.[1]: https://odin-lang.org/docs/overview/#implicit-context-system