[Swift-devel] Standard Library Proposal/Discussion Page

Yadu Nand Babuji yadunand at uchicago.edu
Thu Jan 22 14:14:04 CST 2015


Hi MIhael,



Now that I write that snippet/pseudocode, I think baseName and dirName 
would also be useful.

Perhaps stat, is redundant because I can use a mapper for the same result.

How do you loop sanely in swift. Well that is a tough question.




On 01/22/2015 12:41 PM, Mihael Hategan wrote:
> On Thu, 2015-01-22 at 12:17 -0600, Yadu Nand Babuji wrote:
>> Hi Mihael,
>> e
>> I have a request for the some features similar to those provided by
>> python's os library:
>>
>> getcwd
> Sure. Perhaps getEnv()?
Sure getEnv works just as well.
>> 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 );

I do not have a use-case that generates large intermediate files, which 
need to be removed mid-way through processing.

>> stat          ( For loops which stat for new files )
> Stat on a given file, yes (and there are some question marks there,
> too), stat to poll for files being added to a directory? I'm not sure.
> How do you even loop sanely in swift? Do you have a specific
> need/example?

Perhaps stat is redundant since you can do the same check with a mapper ?

I do not know how to answer the "how to loop sanely" question.
The example is the same is the one above.
>> system     ( fix ? )
> Sure. Although I'd like Tim's and Justin's input on this.
> Mihael
>




More information about the Swift-devel mailing list