[swift-evolution] ed/ing, InPlace, Set/SetAlgebra naming resolution
Craig Cruden
ccruden at novafore.com
Sat Feb 13 14:31:35 CST 2016
OK, I understand but it seems a little messy - basically overloading with two copies of every function on the “same” data structure.
With many collections it would lead to the underlying data structures within the collections would either end up being optimized for mutable or immutable.
In many cases the way you store the data internal to the collection would be more efficient if focused on one or the other — but not both.
I just view a mutable collection of the same “type” as fundamentally different than the immutable version of it.
There are probably of course tradeoffs - either way.
I would thought that if you want it “invisible” to the user which data structure you are selecting you would have a mutable implementation of `Set`, and an immutable
version of `Set` and if you used let it would be one implementation, and if var the other implementation — and not the enabling or disabling of certain functions on
the data type.
> On 2016-02-14, at 3:11:54, Brent Royal-Gordon <brent at architechies.com> wrote:
>
>> Is there a reason why the same data structures are supporting both mutable and non-mutable operations?
>
> Because Set is a Swift value type and you can control its mutability by assigning it to a constant or variable, just like an Array.
>
> --
> Brent Royal-Gordon
> Architechies
>
More information about the swift-evolution
mailing list