[Swift-devel] Associative array in Swift [GSoC]
Mihael Hategan
hategan at mcs.anl.gov
Sat Jun 18 19:21:46 CDT 2011
On Sun, 2011-06-19 at 00:11 +0000, Ben Clifford wrote:
> > I see no reason* why the addition operator couldn't be overloaded for
> > arrays to mean "append".
>
> With the control structures that exist now, you need to specify *some*
> index because you can extract that index (not just the values of the
> array) with foreach index,value in a { ...
> }.
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 due to the less
arbitrariness. I mean it's pretty clear why one would say a = a + [1],
or a += [1] or append(a, 1), but not quite sure why I should say a[!] =
1 instead of a[$] = 1 or a[_] = 1.
>
> 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.
More information about the Swift-devel
mailing list