[Swift-devel] Associative array in Swift [GSoC]

Mihael Hategan hategan at mcs.anl.gov
Sat Jun 18 19:57:32 CDT 2011


On Sun, 2011-06-19 at 01:36 +0100, Ben Clifford wrote:
> On Jun 19, 2011, at 1:21 AM, Mihael Hategan wrote:
> 
> > I wasn't discussing an issue of semantics. I think we agree on that. I'm
> > simply saying that I prefer one syntax to the other 
> 
> ok. I'm not overly enthused about the syntax either way.
> 
> >> 
> >> I personally find the idea of expression what looks like a mutating 
> >> concatenation but isn't really to be more distasteful.
> > 
> > Except it is a mutating concatenation. But it's one that is acceptable
> > because there is no way to have code that is nondeterministic because of
> > it. It's a non-destructive mutation.
> 
> do you regard the 2nd statement in:
> 
> a[0] = 4343;
> a[1] = 54354;
> 
> to be mutating?

Looks like it: a_without_it != a_with_it (where it = second statement),
Though, again, swift doesn't allow you to compare a before with a after.
There is no explicit or implicit notion of time or time sequence.

>  if so, then a += 54354; is also a mutating concatenation in that
> definition of the word, and I agree with you. Otherwise I disagree
> with you.

Right. The statement above applies equally well.

> 
> But my perspective is that in a swift run, the 'a' array above has a
> single value, described as: "the 0th element is 4343, and the 1st
> element is 4343" and that the value becomes more accurately known as
> the run progresses until such time as you know its value completely.
> In that sense, the 2nd statement above, and the concatenation-like
> operators discussed in this thread are absolutely not mutating: they
> define the final value and that is all. From that perspective, the
> ability to pipeline based on partial knowledge of that value is
> somewhat accidental.
> 
I agree. Point being that both may look like a mutating operation in
some arbitrary non-swift language, but they are what they are in swift.
So I don't think that a = a + [1] looks more mutating than a[next_index]
= 1. Given that they are equivalent from that perspective, the remaining
deciding factors should be unrelated to this issue. 




More information about the Swift-devel mailing list