Hacker News new | past | comments | ask | show | jobs | submit login

How do you deal with atomicity though? A big deal in Rust is that you can only have one mutable reference to an object at any given time which prevents all sorts of aliasing issues, but here if you have two mutable fat pointers, one to and and one to b, and you attempt to write them without synchronization you're going to have a big problem, won't you?

This is the main risk with bitfields in C, it makes reads and writes that appear to be independent actually access the same memory cell behind the scenes. I'm not convinced by the idea of adding even more magic on top of it to be honest, it is true that packing and unpacking bitfields is annoying and requires some boilerplate but in the end that is how it the hardware does it anyway.




The builtin functions for atomic operations provided by the language do not allow unaligned pointers, so it would be a compile error.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: