fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Warn if atomic field is created on value type, or should atomic be `ref`?

Open michaellilltokiwa opened this issue 1 year ago • 2 comments

some_feat is
  x := atomic i32 3

If we use some_feat and pass it around, copies are made of x, which I think is a racy_read and also probably not what is intended.

michaellilltokiwa avatar Aug 29 '24 14:08 michaellilltokiwa

Maybe instead of forbidding atomics in a value type, we could have a property.not_cloneable (or not_clonable?), let atomic inherit from this property and flag an error if a value that is not_cloneable is passed as a value?

fridis avatar Apr 17 '25 08:04 fridis

Another possibility that might be easier is to make atomic a ref. I find this a little unsatisfactory since it adds a level of indirection in many cases where this is not needed.

fridis avatar Apr 17 '25 09:04 fridis