[Swift-devel] New syntax for appending to arrays

Ian Foster foster at anl.gov
Tue Jun 28 09:08:30 CDT 2011


$0,02 from me -- given that Swift has a C-like syntax, this syntax will surely confuse people??

On Jun 28, 2011, at 9:04 AM, Michael Wilde wrote:

> This sound good.  I assume one should be able to append to any dimension of a multi-dimensional array with +=.
> 
> int a[][];
> 
> a[5] += 1
> a[5] += 2
> 
> sets a[5][?] = 1
>     a[5][?] = 2
> 
> where ? is the index values chosen by +=
> 
> Further, as you work out the typing rules for array subscripts, should the following work?
> 
> int a[][[];
> int b[];
> b += 100;
> b += 200;
> a += b;  # <=== should this append a new array to a?
> 
> - Mike
> 
> ----- Original Message -----
>>> As proposed earlier, a new syntax for appending values to
>>> arrays have been implemented. Examples are given below.
>> 
>> I think I have been won over to the += syntax.
>> 
>>> Please note that, we still need to make sure that when we can
>>> only append to an array, so to associate keys and multiple
>>> values, (i think) we will need two(or more) dimensional arrays.
>> 
>> yes. but there are already multi-dimensional arrays in swift.
>> 
>> also, a one dimensional array should still work, like this:
>> 
>> int a[];
>> a += 232;
>> a += 111;
>> 
>> --
> 
> -- 
> Michael Wilde
> Computation Institute, University of Chicago
> Mathematics and Computer Science Division
> Argonne National Laboratory
> 
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel




More information about the Swift-devel mailing list