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

Ben Clifford benc at hawaga.org.uk
Sun Jun 19 02:41:16 CDT 2011


On Jun 19, 2011, at 7:32 AM, Tim Armstrong wrote:

> Maybe I missed something, but from the discussion I'm not quite clear about what the use case is.
> 
> It seems like there are three possibilities for the data structure:
> 
> 1 Order is completely unimportant (i.e. the data structure is a set or multi-set)
> 2 Relative order is important (i.e. if the assignment happens in a later iteration of a for loop, it should be later in the list)
> 3 Absolute order is important - i.e. we're using explicit array indices
> 
> It seems like you're proposing 2, which seems a bit odd to me in the context of swift as it adds some kind of sequential dependency between iterations of a for loop when determining array indices.

i was proposing 1 from the above. The key difference from I think what you've seen (and a bit of the basis of what hategan and I were debating about) was in the nature of the fabricated key.

My proposal was that the index was that the fabricated key is allocated in a loop in some way that does not need any of the other iterations to have executed (that's the thread ID or the program context + loop context stuff that was mentioned in this thread). Thats going to look a bit pseudo-random to someone who doesn't know the details of swift's execution internals.

I was, I guess, suggesting a syntax that means:

> That is kind of clunky though.  Would it be possible to have some kind of syntax for implicitly flattening arrays, e.g.:
...

>      output[i,j] = f(i,j)

"order is completely unimportant for me, so make up this [i,j] for me so that i don't have to think if I've accurately captured the enclosing loop context"

-- 


More information about the Swift-devel mailing list