Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #26333

Re: Co-routines a la Knuth

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Co-routines a la Knuth
Date 2013-10-05 14:15 -0700
Organization Nightsong/Fort GNOX
Message-ID <7xr4bzto6h.fsf@ruckus.brouhaha.com> (permalink)
References <6b24531a-7c25-4a3e-9b60-21af2bb89dae@googlegroups.com>

Show all headers | View raw


mhx@iae.nl writes:
> I found a co-routine implementation that doesn't use the R-stack 
> at all and only needs a single variable. (It is a special case.)

The GA144 has a machine instruction for that.  It just swaps R (the top
of the return stack) with the program counter.

> Prof. Knuth has one convincing example for co-routines: They may
> make it unnecessary to save a temporary copy. 

A traditinal example is getting rid of the control inversion that it
takes to process a i/o stream using ordinary subroutine calls, while
keeping the i/o separate from the processing code:

  http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Co-routines a la Knuth mhx@iae.nl - 2013-10-05 11:50 -0700
  Re: Co-routines a la Knuth Paul Rubin <no.email@nospam.invalid> - 2013-10-05 14:15 -0700
    Re: Co-routines a la Knuth mhx@iae.nl - 2013-10-06 03:22 -0700
      Re: Co-routines a la Knuth mhx@iae.nl - 2013-10-06 09:58 -0700
  Re: Co-routines a la Knuth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-07 12:33 +0000
    Re: Co-routines a la Knuth m.a.m.hendrix@tue.nl - 2013-10-07 07:17 -0700
      Re: Co-routines a la Knuth mhx@iae.nl - 2013-10-07 13:43 -0700
        Re: Co-routines a la Knuth "Elizabeth D. Rather" <erather@forth.com> - 2013-10-07 12:58 -1000
          Re: Co-routines a la Knuth mhx@iae.nl - 2013-10-08 23:58 -0700
            Re: Co-routines a la Knuth "Elizabeth D. Rather" <erather@forth.com> - 2013-10-08 21:08 -1000
      Re: Co-routines a la Knuth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-08 15:05 +0000
        Re: Co-routines a la Knuth mhx@iae.nl - 2013-10-09 13:23 -0700

csiph-web