Re: New version of C-like interpreter available

Steven D. Majewski (sdm7g@elvis.med.Virginia.EDU)
Mon, 18 Apr 1994 15:45:16 GMT

In article <CoB4tz.BL9@jmm.pickering.elegant.com>,
John Macdonald <jmm@jmm.pickering.elegant.com> wrote:
>
>Having handle objects and having co-routines should make it very
>simple to build a library for doing exactly that. A handle
>object read/write routine would be set up as a simple sub-routine
>in many cases - when ever it does not need to keep much extra
>state and nested functional state hanging around - but would be
>set up as a co-routine in the more complicated variations.

[ Well - even though this thread has been mostly about Perl,
it's still being posted to comp.lang.misc, so I'll reply. ]

That is exactly ( and ALL ) that is needed.
The Python example I posted, used the fact that any object which
supports read/readline/readlines or write/writelines methods
can be used in place of a (builtin) file-object. ( The Python
equivalent of a Perl "handle object" )

It is quite easy to redirect the output of a Python program
to it's calling function.

In the version I posted, the inner function must run to
completion before producing any output. This is because
the redirection is being done by a wrapper function
( redirect.tolines ) that captures the output and
returns it to the caller, and so the semantics are not quite
the same a unix pipes.

Objects can be induced to do a lot of the things that co-routines
can do (see several versions of generators and defered evaluation
sequences that have been posted to comp.lang.python), but in this
case, a real co-routine is necessary for 2 way communication
without blocking, so that a read of data from the inner function,
causes it to run until it write some data out ( which causes the
outer calling function to resume. )

-- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU> --
-- UVA Department of Molecular Physiology and Biological Physics --
-- Box 449 Health Science Center Charlottesville,VA 22908 --
[ "Cognitive Science is where Philosophy goes when it dies ...
if it hasn't been good!" - Jerry Fodor ]