News for hackers. Stuff that matters.
Re:What Makes the Zig Programming Language Unique? by lhorie on Wednesday October 05, 2022 @09:57PM (#33103436)
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?
Re:What Makes the Zig Programming Language Unique? by evil-olive on Wednesday October 05, 2022 @10:08PM (#33103496)
regular 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

Re:What Makes the Zig Programming Language Unique? by tomcam on Wednesday October 05, 2022 @10:25PM (#33103609)
With respect, I’m not sure that answered the question. Surely in a sudoku game the default layout of structs would be absolutely fine, no?
Re:What Makes the Zig Programming Language Unique? by evil-olive on Wednesday October 05, 2022 @10:29PM (#33103634)
ahh, 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.

Re:What Makes the Zig Programming Language Unique? by lhorie on Wednesday October 05, 2022 @10:36PM (#33103670)
Yes, I meant in your sudoku solver, sorry, I should've been more clear.