Comment by smj-edison

Comment by smj-edison 10 hours ago

2 replies

I can't speak as much about the last two examples, but writing a giant parser file is pretty common in Zig from what I've seen. Here's Zig's own parser, for example[1]. I'm also not sure what you mean by memory unsafe, since all slices have bounds checks. It also looks like this uses an arena allocator, so lifetime tracking is pretty simple (dump everything onto the allocator, and copy over the result at the end). Granted, I could be misunderstanding the code, but that's the read I get of it.

[1] https://codeberg.org/ziglang/zig/src/commit/be9649f4ea5a32fd...

dgroshev 4 hours ago

As it happens, the commit I linked fixes a segfault, which shouldn't normally happen in memory-safe code.