Would the new atomic break the generic code?

Not all code can be made composable, and code which accesses struct internals is usually not expected to be (as we don’t have inheritance of struct fields). Instead, it’s usually expected that composability happens via multiple dispatch, so choosing behavior based on the type of the struct, instead of the contents and layout of the object.

Upgrading non-atomic writes doesn’t necessarily do the right thing, you really need to write your accesses in a manner which is fully aware of the fact that you’re accessing an atomic field.

2 Likes