[Swift-devel] Feedback loops in swift fails with deeper recursion

Mihael Hategan hategan at mcs.anl.gov
Wed Jun 12 19:07:09 CDT 2013


Yep. I can see why this is happening.

Please put this in bugzilla.

Mihael

On Wed, 2013-06-12 at 14:19 -0500, Yadu Nand wrote:
> Hello Mike,
> 
> Sorry about the crude example and even worse explanation.
> 
> I'm trying to implement a simple feedback pattern in swift. Here's
> what I have : An application foo( ), which feeds back its output till
> ome condition cond( ) returns true. cond( ) just checks if a counter
> in the file has reached 100. The work( ) app, increments the counter
> in the input file by 1. Thus the following pseudo swift code should go
> to a 100 level deep recursion.
> 
> (file output) foo (file input) {
>        if ( input meets conditions ){
>              output = input; // tail end of recursion
>        } else {
>              // do some work on input and pass it back to foo ( )
>              file temp = work (input);
>              output = foo ( temp );
>        }
> }
> 
> From what I understand here, the concurrent mapper is creating
> temporary files by appending the filename at each level of the
> recursion with some chars resulting in filenames exceeding the 255
> char limit by the 50th level. I did not know at the time when this
> mail was sent out that I could just tell the mapper to name the files
> differently.
> 
> I could also have used an array of files with the recursion level as
> index to retain the file's progress through the recursion and use the
> level as an index to previous results.
> 
> Thanks,
> Yadu
> 
> On Wed, Jun 12, 2013 at 11:53 AM, Michael Wilde <wilde at mcs.anl.gov> wrote:
> > Yadu, I find your example hard to understand.  Can you clean it up to show what you are really trying to do here?
> >
> > I dont see where cond changes to terminate the recursion.
> >
> > Presumably its either for creating a test or for learning the language, but as-it its a bit confusing.
> >
> > It would also help to show the full script.
> >
> > If Swift's "concurrent" (default) mapper keeps extending the file name, you should map the files involved explicitly to a name that uses a short integer thats passed as an argument.
> >
> > - Mike
> >
> >
> > ----- Original Message -----
> >> From: "Yadu Nand" <yadudoc1729 at gmail.com>
> >> To: "swift-devel" <swift-devel at ci.uchicago.edu>
> >> Sent: Wednesday, June 12, 2013 11:35:55 AM
> >> Subject: [Swift-devel] Feedback loops in swift fails with deeper recursion
> >>
> >> The following recursion loop fails at depth >= 50. Swift is
> >> generating
> >> intermediate files by appending
> >> a string to the end of each intermediate file (in my case 5 chars).
> >> At
> >> depth 50 this exceeds the 255
> >> char limit on file names and swift fails with an -1 error code from
> >> the user application which could
> >> not create the filename swift gave it.
> >>
> >> (tested on Swift 0.94 swift-r6414)
> >>
> >> // Recursion loop
> >> (file out) reiterate (file input, int cond){
> >>       int rval = readData(input);
> >>       //tracef("Content passes to reiterate is = %i \n", rval);
> >>       if ( check(input, cond) == 1 ){
> >>         out = input;
> >>         tracef("Reached tail end. Terminating! \n");
> >>       }else{
> >>         //file temp = process(input);
> >>         //out = reiterate(temp, cond);
> >>         out = reiterate(process(input), cond);
> >>       }
> >> }
> >>
> >> Is there a better way to do feedback of results from the app to
> >> itself? Having the app rewrite the input
> >> file with the result is IMHO a hack.
> >>
> >> -Yadu
> >> _______________________________________________
> >> 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