Avatar
このスレッド、元の話はともかく、↓とかは同じことを話してるよね? The issue with changing .swapTo (et al.?) to nonmutating is that semantically it really is a mutation. But pointers as collections have different mutation semantics to other collections: Mutating an Array’s storage is the same as mutating its value, whereas a pointer’s value is its address, not its storage. Making the Unsafe*Pointer MutableCollection methods themselves nonmutating probably wouldn’t be a source-breaking change (it’d just lower the “bar of entry” to include let constant instances too). I imagine this is noncontroversial. https://forums.swift.org/t/why-does-the-withunsafemutablebufferpointer-closure-take-an-inout-parameter/6794/10 (edited)
A lot of the MutableCollection implementation is in protocol extensions (swapAt, for example.) Should an additional version be written just for the Unsafe*BufferPointer types? Makes sense to me, given the examples above. It doesn’t seem to be a high priority task thou...