[Swift-devel] Standard Library Proposal/Discussion Page

Mihael Hategan hategan at mcs.anl.gov
Thu Jan 22 18:04:29 CST 2015


On Thu, 2015-01-22 at 14:55 -0600, Yadu Nand Babuji wrote:
> Replies inline
> 
> -Yadu
> On 01/22/2015 02:46 PM, Mihael Hategan wrote:
> > On Thu, 2015-01-22 at 14:14 -0600, Yadu Nand Babuji wrote:
> >>>> remove    (/rm)
> >>>> move ?    ( python doesn't seem to have this)
> >>> Like move and remove files? Do you have an example of how these would be
> >>> used?
> >> I remember a case where a directory is actively getting filled with data
> >> that needs to be processed.
> >> So, we map the input_queue directory, "move" the file to the active
> >> directory and start the processing.
> >>
> >> file active_files[] <simple_mapper; location="active_list", prefix="active"> ;
> >> file completed[];
> >>
> >> iterate ( ){
> >>       file new_files[] = <simple_mapper; location="input_queue", prefix="foo">;
> >>       foreach f in new_files{
> >>           move ( f, active_files[length(active_files)] );          # We move the file, so that it is not processed again in the next round.
> >>           completed[length(completed)] = process(active_file);
> >>           sleep(60);
> >>       }
> >> }until ( status == 10000 );
> > Does this work without move()? Say, by doing the move in a script as
> > part of process()?
> Of course, that is possible. The only reason I though that an explicit 
> move/remove would make sense is because
> I think swift should be handling the movement of files involved in the 
> run. Perhaps this isn't as clean as I thought it'd be.

I asked because there are a number of issues with that script. For
example, the statement a[length(a)] = x should deadlock. So I wanted to
know if the rest of the script works.

It is not clean, or at least I don't see how it can be made clean. In
particular because no function in swift should behave differently
depending on when it is run or if it is run multiple times. This is
called referential transparency and it says that all f(x) will always
have the same value when invoked with the same x. It is the only way I
know to guarantee that the not-fully-specified ordering of execution in
swift results in correct programs.

The problem with move would be that the second invocation of move with
the same parameters will have to fail or do nothing since you've already
moved the file.

Maybe I'm wrong. Thoughts?

Mihael




More information about the Swift-devel mailing list