Set-only subscripts

I'm not sure this is a good idea. Semantically, a set-only subscript or property is just a mutating method, so this amounts to a different syntax for writing a mutating method. By expanding the constraints on subscripts and properties, we weaken their meaning. For example, seeing x[b] = y in valid code no longer means you can write x[b].mutatingMethod(). So it's not obvious to me that this change improves the language overall. I can see that it increases symmetry (between get and set) but that is a benefit to the writer that potentially hurts the reader.

14 Likes