[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10. Pipeline implementation

It is important that the features just described be implemented without extraneous forks or copying of temporary values. The difficulty is that what is a reasonable implementation in one context is inefficient in another context.

The Q evaluator does keeps track of the "result" context. To run a program in the default context Q must allocate an expandable buffer, copy all of the output from the program into the buffer, and then create a string using the buffer. But if the context is such that the result will be piped as standard input to another program, then the run command will be evaluated in a "pipe" context. In that case the evaluator just creates a pipe, has the program write to one end of the pipe, and passes the other end of the pipe to the other program. Similarly, if the context is one where the result will just be printed (such as the top-level read-evaluate-print loop), then Q can evaluate a run command by just letting the program's standard output print without re-direction.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Per Bothner on December, 4 2001 using texi2html