[Swift-devel] New syntax for appending to arrays
Yadu Nand
yadudoc1729 at gmail.com
Tue Jun 28 13:51:44 CDT 2011
> You could approach this at the type level too, if you're putting types for indices.
> A user can only specify ["!"] as an index if the array takes a string in that position.
> You could have a different type (for the sake of argument called 'auto' (cue another naming discussion)) for automatically assigned indices. (which in the implementation under question are thread IDs - but that's an accident of implementation).
> So if I am going to say array[2] += 10; then array must have been declared with type:
> int array[int][auto];
> and if I'm going to say
> array[2]["!"] = 10; (meaning, use key "!", not use an automatically assigned variable)
> then array must be declared as:
> int array[int][string].
> In that approach, it is a type checking error to either use += on a non-auto array, or specify an explicit string or int index on an auto array.
> You could then have variables with type auto, which you could extra auto values into through foreach, but not other wise being able to specify auto values.
This is great. This would solve other problems as well.
But, involves changing array definition as well as lot of
code changes, almost everyplace arrays are handled.
I'll try to get this done.
--
Thanks and Regards,
Yadu Nand B
More information about the Swift-devel
mailing list