[Swift-devel] Join function?

Jonathan Monette jonmon at mcs.anl.gov
Tue Apr 3 17:17:40 CDT 2012


So swift r4755 has code that will wait for the array to be closed using waitFor().  However, swift r4756 has the new code which uses the size of a map.  The svn log does not say why.  I am reverting the code for the length function to r4755.

On Apr 3, 2012, at 5:13 PM, Jonathan Monette wrote:

> When length was first added it created handle and would throw a Future exception if the array that was passed as an argument was not closed.  Now the code gets a map and returns the map size.  I am looking through the svn log to find out why that change was made.
> 
> Do you know why?
> 
> On Apr 3, 2012, at 5:10 PM, Mihael Hategan wrote:
> 
>> Just add "handle.waitFor();" before getting the length.
>> 
>> On Tue, 2012-04-03 at 17:04 -0500, Jonathan Monette wrote:
>>> That's exactly what is happening.  I am looking at it right now.  I am going to try a fix and do some tests.  I'll report back when it is fixed.
>>> 
>>> On Apr 3, 2012, at 4:59 PM, Mihael Hategan wrote:
>>> 
>>>> Maybe it didn't wait for the array to be closed?
>>>> 
>>>> On Tue, 2012-04-03 at 16:13 -0500, Michael Wilde wrote:
>>>>> for an array created like this:
>>>>> 
>>>>> string a[] = ["a","b","c"];
>>>>> 
>>>>> @length(a) returned 3 when called from open code, but when applied to the argument s[] inside a function, to which a was passed, returned 0 inside that function.
>>>>> 
>>>>> In trying to replicate this without divulging the source code to recursive strjoin() ;) which I was leaving as an exercise to the (email) reader, I see that there is further weirdness, likely due to confusion/race between @length() and array closing semantics.
>>>>> 
>>>>> For example:
>>>>> 
>>>>> com$ cat length.swift
>>>>> string a[] = ["a","b","c"];
>>>>> 
>>>>> string b[];
>>>>> b[0] = "a";
>>>>> b[1] = "b";
>>>>> b[2] = "c";
>>>>> 
>>>>> (string o) strjoin(string s[], string sep)
>>>>> {
>>>>> #  o = strjoinf(s, sep, @length(s));  # length returns 0 here!
>>>>> trace("len inside", at length(s));
>>>>> 
>>>>> }
>>>>> 
>>>>> trace("len a outside", @length(a));
>>>>> trace("len b outside", @length(b));
>>>>> 
>>>>> string js = strjoin(a,"---");
>>>>> 
>>>>> ####
>>>>> 
>>>>> Gives this non-determinsitic output:
>>>>> 
>>>>> com$ swift length.swift
>>>>> 
>>>>> no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml
>>>>> Swift trunk swift-r5739 cog-r3368 (cog modified locally)
>>>>> 
>>>>> RunID: 20120403-1559-ulurhdrf
>>>>> Progress:  time: Tue, 03 Apr 2012 15:59:31 -0500
>>>>> SwiftScript trace: len b outside, 2
>>>>> SwiftScript trace: len inside, 3
>>>>> SwiftScript trace: len a outside, 3
>>>>> Final status: Tue, 03 Apr 2012 15:59:31 -0500
>>>>> 
>>>>> com$ swift length.swift
>>>>> 
>>>>> no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml
>>>>> Swift trunk swift-r5739 cog-r3368 (cog modified locally)
>>>>> 
>>>>> RunID: 20120403-1559-x3ovo0i6
>>>>> Progress:  time: Tue, 03 Apr 2012 15:59:39 -0500
>>>>> SwiftScript trace: len b outside, 2
>>>>> SwiftScript trace: len a outside, 0
>>>>> SwiftScript trace: len inside, 0
>>>>> Final status: Tue, 03 Apr 2012 15:59:39 -0500
>>>>> 
>>>>> com$ swift length.swift
>>>>> 
>>>>> no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml
>>>>> Swift trunk swift-r5739 cog-r3368 (cog modified locally)
>>>>> 
>>>>> RunID: 20120403-1559-zkglev13
>>>>> Progress:  time: Tue, 03 Apr 2012 15:59:42 -0500
>>>>> SwiftScript trace: len b outside, 3
>>>>> SwiftScript trace: len a outside, 0
>>>>> SwiftScript trace: len inside, 0
>>>>> Final status: Tue, 03 Apr 2012 15:59:42 -0500
>>>>> 
>>>>> com$ swift length.swift
>>>>> 
>>>>> no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml
>>>>> Swift trunk swift-r5739 cog-r3368 (cog modified locally)
>>>>> 
>>>>> RunID: 20120403-1559-5ttgglqc
>>>>> Progress:  time: Tue, 03 Apr 2012 15:59:48 -0500
>>>>> SwiftScript trace: len a outside, 0
>>>>> SwiftScript trace: len b outside, 3
>>>>> SwiftScript trace: len inside, 3
>>>>> Final status: Tue, 03 Apr 2012 15:59:48 -0500
>>>>> com$ 
>>>>> 
>>>>> 
>>>>> ----- Original Message -----
>>>>>> From: "Jonathan Monette" <jonmon at mcs.anl.gov>
>>>>>> To: "Mihael Hategan" <hategan at mcs.anl.gov>
>>>>>> Cc: "Glen Hocky" <glen842 at uchicago.edu>, "swift-devel at ci.uchicago.edu Devel" <swift-devel at ci.uchicago.edu>
>>>>>> Sent: Tuesday, April 3, 2012 3:47:18 PM
>>>>>> Subject: Re: [Swift-devel] Join function?
>>>>>> I do not know what Mike was experiencing. I was going to investigate
>>>>>> myself and ask what his example was. Perhaps he can elaborate more on
>>>>>> what he was witnessing.
>>>>>> 
>>>>>> On Apr 3, 2012, at 3:46 PM, Mihael Hategan wrote:
>>>>>> 
>>>>>>> On Tue, 2012-04-03 at 15:43 -0500, Jonathan Monette wrote:
>>>>>>>> So Swift does have an @length built-in function that returns the
>>>>>>>> length of an array. Mike said he also tried coming up with a Swift
>>>>>>>> function to this same think and said that @length does not always
>>>>>>>> behave as he thought it should. I am going to look into fixing
>>>>>>>> @length so we do have a way finding the length of an array.
>>>>>>> 
>>>>>>> Can you be more specific as to what's wrong with @length?
>>>>>>> 
>>>>>> 
>>>>>> _______________________________________________
>>>>>> Swift-devel mailing list
>>>>>> Swift-devel at ci.uchicago.edu
>>>>>> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
>>>>> 
>>>> 
>>>> 
>>> 
>> 
>> 
> 
> _______________________________________________
> 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