[Swift-devel] array_mapper hangs
wilde at mcs.anl.gov
wilde at mcs.anl.gov
Sat Mar 20 10:49:51 CDT 2010
Examining this more closely, there is indeed "surprising behavior" in @filenames() (plural) evaluation, but I don't think it was affecting Sarah's original program.
Assuming the intention of maptest() was to test if the array_mapper was working as expected, the following variation am5.swift of Sarah's script works correctly and traces the mappings.
But the second variation on it, am6.swift, which uses @filenames() to fetch the mappings, hangs.
Its possible that you can't do @filenames() (plural) on an unclosed array, and that this behavior is consistent with current Swift semantics. I am guessing that since Swift doesn't know how many elements the argument array to @filenames() has if its not set/closed, that it blocks until its argument array is closed.
am5.swift works and prints the mappings:
$ cat am5.swift
type file;
app (file o) echo (string s) { echo s stdout=@o; }
# original mappings
string outfilenames[];
string conditions[] = ["rest1","emblem"];
foreach cond,c in conditions{
outfilenames[c] = @strcat(cond,"_physio.dat");
}
file f[] <array_mapper;files=outfilenames>;
# test the mappings
(string mappings[] ) maptest(file physD[]) {
mappings[0] = @filename(physD[0]);
mappings[1] = @filename(physD[1]);
}
string m[];
m = maptest(f);
foreach s,i in m {
trace("i", i, "s", s);
}
$ swift am5.swift
Swift svn swift-r3264 (swift modified locally) cog-r2730 (cog modified locally)
RunID: 20100320-1044-2jj6h45a
Progress:
SwiftScript trace: i, 0, s, rest1_physio.dat
SwiftScript trace: i, 1, s, emblem_physio.dat
Final status:
am6.swift hangs:
$ cat am6.swift
type file;
app (file o) echo (string s) { echo s stdout=@o; }
# original mappings
string outfilenames[];
string conditions[] = ["rest1","emblem"];
foreach cond,c in conditions{
outfilenames[c] = @strcat(cond,"_physio.dat");
}
file f[] <array_mapper;files=outfilenames>;
# test the mappings
(string mappings[] ) maptest(file physD[]) {
foreach fname, i in @filenames(physD) { # <--- hangs here?
mappings[i] = fname;
}
}
string m[];
m = maptest(f);
foreach s,i in m {
trace("i", i, "s", s);
}
$ swift am6.swift
Swift svn swift-r3264 (swift modified locally) cog-r2730 (cog modified locally)
RunID: 20100320-1044-slm1fdt8
Progress:
^^^ Hangs.
- Mike
----- wilde at mcs.anl.gov wrote:
> Also, to clarify: Ben is right in pointing out that this part of my
> earlier reply:
>
> "Ie, at the point at which it wants a value for physD[0] and
> physD[1]..." is irrelevant. The problem, I think, is the fact that a
> return value was never set in maptest().
>
> So I *think* that Swift is behaving correctly in your original script,
> Sarah, and in all the tests I've tried based on it.
>
> - Mike
>
> ----- wilde at mcs.anl.gov wrote:
>
> > I think the script is hanging because its trying to return physD[]
> > without ever setting the return array parameter physD (or any
> member
> > of it):
> >
> > app (file physD[]) maptest(){
> > > touch @filename(physD[0]) @filename(physD[1]);
> > > }
> >
> > The following examples don't use @filename in maptest. am3.swift
> > hangs, am4.swift works. The difference is that am4 puts a value in
> f[]
> > and am3 does not.
> >
> > ::::::::::::::
> > am3.swift
> > ::::::::::::::
> > type file;
> >
> > app (file physD[]) maptest() {
> > echo "hi";
> > }
> >
> > file f[];
> >
> > f = maptest();
> > ::::::::::::::
> > am4.swift
> > ::::::::::::::
> > type file;
> >
> > app (file o) echo (string s) { echo s stdout=@o; }
> >
> > (file physD[]) maptest() {
> > physD[0] = echo("hi");
> > }
> >
> > file f[];
> >
> > f = maptest();
> > $
> >
> >
> > ----- "Ben Clifford" <benc at hawaga.org.uk> wrote:
> >
> > > > The script is hanging because its trying to access the values
> of
> > the
> > >
> > > > array object f[], which is never set. Ie, at the point at which
> > it
> > > wants
> > > > a value for physD[0] and physD[1], physD itself - even though
> it
> > has
> > >
> > > > been *mapped* - has never been given a *value.
> > >
> > > Sarah's script doesn't ask for the values of physD[i]. It asks
> for
> > the
> > >
> > > @filename of them. That 'should' work for anything that has been
> > > mapped
> > > even if it doesn't have a value.
> > >
> > > --
> >
> > --
> > Michael Wilde
> > Computation Institute, University of Chicago
> > Mathematics and Computer Science Division
> > Argonne National Laboratory
> >
> > _______________________________________________
> > Swift-devel mailing list
> > Swift-devel at ci.uchicago.edu
> > http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
>
> --
> Michael Wilde
> Computation Institute, University of Chicago
> Mathematics and Computer Science Division
> Argonne National Laboratory
>
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
--
Michael Wilde
Computation Institute, University of Chicago
Mathematics and Computer Science Division
Argonne National Laboratory
More information about the Swift-devel
mailing list