Placement allocation / specifying an allocator ============================================== When using arena allocation, and also to make things more efficient, one will often want to use custom allocation when creating a new object. So when a function directly or indirectly creates something that would be allocated on the heap, we need to have a parameter (or a thread-local variable) to specify the allocator. (Also, there may be some cases where you want to always use the heap, such as for lazy initialization and libraries that do built-in caching etc.) The allocator needs to contain this info at least: - Type of allocator - Allocator specific data, e.g. pointer to allocation area type Allocator = case struct ( .Heap ( ) # FIXME it is probably better to return a non-pointer struct value in this case? (i.e. stack return) #.MergedImplicitSize ( # []byte data #) .MergedFixedSize ( size len [len]byte data ) .FixedSize ( size len rwref [len]byte data ) .Arena ( rwref Arena arena ) # if we alloc function pointers .CustomAllocator ( ) )