[Swift-user] Error: Attempted to close nonexistent channel buffers
Ben Clifford
benc at hawaga.org.uk
Thu Sep 13 16:38:36 CDT 2007
On Thu, 13 Sep 2007, Allen, M. David wrote:
> (file headlines) getHeadlines(blog b) {
> app {
> feeder @b.feedURL stdout=@filename(headlines);
> }
> }
probably unrelated, but b.feedURL is a string not a file, so you should
probably say "b.feedURL" rather than "@b.feedURL" - that will pass the
feedURL string as a parameter to the feeder program.
@foo means the same as @filename(foo) which only makes sense when foo is a
file.
> (string matches) findSingleMatch(file input, string searchTerm) {
> app {
> grep "-i" searchTerm @filename(input) stdout=@matches;
> }
> }
more of a problem is here: data in Swift is either 'in memory' - like ints
or strings or floats, or 'in files' - you can't really mix the two.
The stdout=@matches line treats matches as a file, but then later on you
treat it as an 'in memory' value. That is not allowed.
> (file matches) findMatches(file inputs[], string searchTerm) {
> string final;
>
> foreach input, index in inputs {
> string intermed = findSingleMatch(input, searchTerm);
> final = strcat(final, intermed);
> }
>
> matches = dumpString(final);
> }
Another problem here is trying to assemble the values into a final
collection in the way you are trying to.
Here's a program which does similar, but using only files, rather than
swiftscript in-memory values:
type messagefile;
(messagefile t) greeting(string s) {.
app {
echo s stdout=@filename(t);
}
}
(messagefile o) join(messagefile s[]) {
app {
cat @filenames(s) stdout=@o;
}
}
messagefile outfile <"001-echo.out">;
messagefile qqqfile <"b001-echo.out">;
outfile = greeting("monkeys");
qqqfile = greeting("monkeys22");
messagefile everything <"output.txt">;
everything = join([outfile, qqqfile]);
--
More information about the Swift-user
mailing list