4 ms·
Just out of curiosity, in your opinion what's the benefit of using a packed struct and all the generated bit fiddling compared to just a regular struct? Just be
by lhorie 4y ago
Just out of curiosity, in your opinion what's the benefit of using a packed struct and all the generated bit fiddling compared to just a regular struct? Just better memory consumption?
- evil-olive 4y agoregular structs in Zig have an implementation-defined layout in memory - the compiler is allowed to re-order fields, add padding, etc. if you want control over the memory layout you need either a packed struct or an extern struct [0]. 0: https://ziglang.org/documentation/0.9.1/#extern-struct https://ziglang.org/documentation/0.9.1/#extern-struct
- tomcam 4y agoWith respect, I’m not sure that answered the question. Surely in a sudoku game the default layout of structs would be absolutely fine, no?
- evil-olive 4y agoahh, I might have misunderstood the question - I wasn't sure if they were asking about Zig in general or my solver in particular. yes, normal structs would have worked fine - like I said, I was learning Zig in the process, so I was going out of my way to experiment with its unique features.
- lhorie 4y agoYes, I meant in your sudoku solver, sorry, I should've been more clear.