Re:Revisiting the design approach to Zig
by messe on Tuesday September 06, 2022 @09:50AM
(#32737105)
To add to that, it's also idiomatic for external libraries in Zig to take an allocator as arguments, rather than using the libc's malloc like a lot of C libraries do.
[ Parent
| on HN ]
Re:Revisiting the design approach to Zig
by girvo on Tuesday September 06, 2022 @10:07AM
(#32737305)
Which as an aside, is a lovely feature when you’re doing things like working with external SPI PSRAM and rightfully want to treat it differently to your local SRAM in embedded applications.
We didn’t use Zig for our firmware, but we did come up with a similar approach in Nim (basically a neat type that takes allocators/frees/reallocs and handles managing the ref count so you can use the variable as any other Nim variable. It’s not perfect, but close enough for our purposes)