[Swift-devel] New syntax for appending to arrays

Ben Clifford benc at hawaga.org.uk
Wed Jun 29 09:32:43 CDT 2011


> > (as in the example a["foo"] += "bar" )
> Yes, but foreach loops don't allow indices to be non-int. I still haven't
> fixed that.

ok

> > Porbably you shoudl treat the thread ID as opaque and only use it in ways
> > that rely on two IDs either comparing equal or not. If you hash it in some
> > way and used that hashed value, then you're going to end up with obscure
> > bugs caused by collisions.
> 
> Yes, when there was no nesting, and appends were done as toplevel-
> statements the thread ids were number like "2" , "0" but when I modified the
> parser to allow appends to be done inside loop-bodies the thread indices
> turned out to be like "0-1-3" , "1-0-3-2-1" etc.. and key collisions are
> happening. Wasn't thread prefixes supposed to be unique ?

Yes.

You shouldn't be seeing multiple threads with the same thread id.

For example, if you do this:

foreach dummy in [1] { 
 foreach i in [1:10] {
    a += i; // or whatever syntax was chosen to be? a << i ?
 }

 foreach value, key in a {
  trace(key);
 }
}

should give 10 unique thread IDs as traced values. Those IDs won't be 
integers in general, though.

-- 




More information about the Swift-devel mailing list