[Swift-devel] Changes to array closing semantics?

Justin M Wozniak wozniak at mcs.anl.gov
Wed Nov 21 13:12:35 CST 2012


On 11/21/2012 10:47 AM, Michael Wilde wrote:
>> int[] a;
>> scope1 {
>> scope2 {
>> a[i1] = v1;
>> f(a);
>> }
>> scope3 {
>> a[i2] = v2;
>> }
>> }
>>
>> and variations.
>>
>>
>> It's not trivial because I need to keep track of both read and write
>> access to variables, and also their respective locations within the
>> scope tree, as well as how iterations and if conditions may affect
>> things. That combined with the general crappiness of the exiting
>> compiler code. But with a bit of work, I think it's doable and it will
>> go miles towards reducing unexpected and perplexing behavior in
>> complex
>> scripts.
>>
> This is something that we should carefully coordinate between Swift/K and Swift/T.
>
> I dont fully understand this issues and differences, but I think that Swift/T has added some restrictions that make array closing simpler to define and implement.
>
> I would like to see us either agree on carying the new semantics forward into Swift/T, or retrofitting Swift/T semantics to Swift/K, to start easing the eventual transition for users.
>
> Thoughts, all?
>
> - Mike
>

I don't think this is currently an issue in the Swift/T implementation 
but I can check.  In Swift/T, we have the restriction that you cannot 
assign to an array A=f() and also do piecemeal assignments A[i]=g() .  
We do track potential write accesses to arrays to keep them open until 
there are no more possible writes.

http://www.mcs.anl.gov/exm/local/guides/swift.html#_arrays

We are currently working on a feature to provide better reporting in 
user error cases.  For example, if a user tries to read from A[3][2] but 
that is never assigned the error output is not very clear but we are 
working on that- we will have to look back to find the original phrasing 
of the lookup.  (Swift/T sets tmp=A[3], looks up tmp[2], and fails- 
currently we can only say that entry [2] of an anonymous array was not 
found, which is not helpful enough.)

     Justin

-- 
Justin M Wozniak




More information about the Swift-devel mailing list