Should allocators be passed in as a value or as a pointer?

To give you an idea of what’s common, there is only one instance in the entire Zig codebase (compiler, standard library, and tests) where a pointer to Allocator is used, and it’s not even the real std.mem.Allocator: test/cases/compile_errors/method_call_with_first_arg_type_wrong_container.zig

(I searched using the regex \*(const )?(std\.)?(mem\.)?Allocator)

And this one instance is very likely a leftover from before “Allocgate”:

So, std.mem.Allocator is always passed by value in the Zig codebase.

6 Likes