[Swift-devel] Explicit subscript type declaration for arrays
Yadu Nand
yadudoc1729 at gmail.com
Thu Jul 7 14:18:21 CDT 2011
Hi,
This week I've been trying to implement support explicit type
declaration for array subscripts. This feature is expected to
fix the earlier issue of subscripts not matching foreach indices.
In addition we'll be able to check the type consistency of
subscripts.
Right now the following piece of code works,
int array[int][string];
array[5] << 10;
array[5] << 20;
foreach v,index in array[5]{
trace (v,index);
trace (array[5][index]);
}
Right now, I'm checking for the basic types already defined as
well as types found earlier on parsing(which I think is the right
behavior), but these are not tested and will take a couple of
days more.
I am pushing all the code, as soon as something works to my
git account [1]. I think this is better than pasting patches, over
mail, which will probably be out-dated fast. The latest commit
with changes enabling explicit subscript types are here[2].
Mihael had pointed out a case in which a struct was used as
subscript. How will such an array be declared ? I am blank
about how struct types. Suggestions and ideas are welcome.
( I really need help! )
[1] https://github.com/yadudoc/Swift
[2] https://github.com/yadudoc/Swift/commit/db5d2cd337e0fb06112b458fdd915659dcb2f153
--
Thanks and Regards,
Yadu Nand B
More information about the Swift-devel
mailing list