4 ms·
It's not true that in zig allocators are always passed around explicitly. You can: - declare a global allocator for your program and call it implicitly everyw
by dnautics 6y ago
It's not true that in zig allocators are always passed around explicitly. You can:
- declare a global allocator for your program and call it implicitly everywhere. This is very accepted by the community as bad practice for libraries but if you are writing end product who cares. In the end in most cases you will have to bootstrap your allocator against a global allocator anyways, and usually that in some form or another std.heap.page_allocator.
- bind an allocator into your struct when you build it. This makes the allocator "implicit" instead of explicit.
The important criteria about red/blue functions that a lot of people forget about is that one of the seams between the two colors is missing. As far as I can tell, for all of "red"/"blue" ish things in zig, (async, allocators, errors) there are clear and documented ways of annealing those seams in your code.