thedarkone2 / gmail.com wrote:
> Adding "atomic" operations to built in `Array`s, `Hash`es etc. is a very bad idea
> because that would force that *all* of the methods on `Array`s and `Hash`es be
> concurrency friendly and would result in irreparable performance problems for
> truly concurrent Ruby VMs (and this again would put an upper limit on Ruby
> performance).

I do atomic operations all the time in C on arbitrary addresses.
Lazy, non-atomic accesses run without speed penalty if I don't need
up-to-date data.

The uncommon case of Array/Hash shrinkage would require RCU or similar
(epoch-based reclamation).  But there's no penalty for reads or in-place
modifications other than the cost of the atomic and required memory
barriers.

Ruby swap/cas (in Ruby) should probably raise on non-existent Array/Hash
elements.