[Swift-devel] arrays of files

Mihael Hategan hategan at mcs.anl.gov
Thu Nov 24 15:05:44 CST 2011


This is something that should be detected at compile time. @filename and
friends accept any type of argument, but it's clear that only types that
have at least one non-primitive component are valid.

I think for 0.93 run-time detection is fine, but the long term solution
is a static check.

Mihael

On Tue, 2011-11-22 at 14:13 -0600, Michael Wilde wrote:
> Replace your prior implementation of bar() with this, and you then have a reall array solution (workaround) until the @filenames() bug is fixed:
> 
> app ( file result ) barapp ( file files[], string s[])
> {
>    ls "-lt" s stdout=@result;
> }
> 
> (file result) bar (file files[] )
> {
>   string s[];
>   foreach f, i in files {
>     s[i] = @filename(f);
>   }
>   result = barapp( files, s );
> }
> 
> - Mike
> 
> ----- Original Message -----
> > From: "Mark Hereld" <hereld at mcs.anl.gov>
> > To: "Michael Wilde" <wilde at mcs.anl.gov>
> > Cc: "swift-devel" <swift-devel at ci.uchicago.edu>, "Thomas D. Uram" <turam at mcs.anl.gov>
> > Sent: Tuesday, November 22, 2011 1:07:32 PM
> > Subject: Re: arrays of files
> > thanks mike! only interested in the array solution. collecting
> > generic patterns that can be easily reused for wide number of
> > situations. gpsi. -- mark
> > 
> > 
> > 
> > On Nov 22, 2011, at 12:05 PM, Michael Wilde wrote:
> > 
> > 
> > 
> > Yup, thanks, Mark - its a bug.
> > 
> > if you change the body of bar to read:
> > 
> > ls "-lt" @filename(files[0]) @filename(files[1]) stdout=@result;
> > 
> > instead of:
> > 
> > ls "-lt" @filenames(files) stdout=@result;
> > 
> > then it works.
> > 
> > I'll file a bugzilla ticket on this. David, can you add to the test
> > suite? Mihael, can you fix it?
> > 
> > Thanks,
> > 
> > - Mike
> > 
> > 
> > ----- Original Message -----
> > 
> > 
> > From: "Mark Hereld" < hereld at mcs.anl.gov >
> > 
> > 
> > To: "Michael Wilde" < wilde at mcs.anl.gov >
> > 
> > 
> > Cc: "Thomas D. Uram" < turam at mcs.anl.gov >
> > 
> > 
> > Sent: Tuesday, November 22, 2011 11:48:17 AM
> > 
> > 
> > Subject: arrays of files
> > 
> > 
> > Mike,
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > this swift seems to compile without complaint but breaks down
> > 
> > 
> > with a null pointer at the last line (invocation of "bar"). i think
> > 
> > 
> > i'm
> > 
> > 
> > confused about arrays of file objects. ideas?
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > type file; app ( file result ) foo ( string args[] ) { ls "-lt" args
> > 
> > 
> > stdout=@result; } app ( file result ) bar ( file files[] ) { ls "-lt"
> > 
> > 
> > @filenames(files) stdout=@result; } file out <"dirlisting.txt">; out =
> > 
> > 
> > foo([".",".."]); file out2 <"nother.txt">; out2 = foo(["/"]); file
> > 
> > 
> > out3 <"proof.txt">; out3 = bar([out,out2]);
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > 
> > 
> > Mark Hereld < hereld at mcs.anl.gov >
> > 
> > 
> > Senior Fellow - Computation Institute
> > 
> > 
> > Experimental Systems Engineer - Mathematics and Computer Science
> > 
> > 
> > Visualization and Analysis Lead - Argonne Leadership Computing
> > 
> > 
> > Facility
> > 
> > 
> > Argonne National Laboratory
> > 
> > 
> > The University of Chicago
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Cell: 630.327.2088
> > 
> > 
> > Voice: 630.252.4170
> > 
> > --
> > Michael Wilde
> > Computation Institute, University of Chicago
> > Mathematics and Computer Science Division
> > Argonne National Laboratory
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > Mark Hereld < hereld at mcs.anl.gov >
> > Senior Fellow - Computation Institute
> > Experimental Systems Engineer - Mathematics and Computer Science
> > Visualization and Analysis Lead - Argonne Leadership Computing
> > Facility
> > Argonne National Laboratory
> > The University of Chicago
> > 
> > 
> > Cell: 630.327.2088
> > Voice: 630.252.4170
> 





More information about the Swift-devel mailing list