[comp.lang.c++] co-routine concept in C++?

bause@exunido.uucp (Falko Bause) (10/11/88)

CO-ROUTINE CONCEPT IN C++
=========================

In an article from Bjarne Stroustrup 'What is "Object-Oriented Programming"?'
(I don't know at the moment where it was published), Stroustrup writes:

'For example, the C++ standard library provides a co-routine class.'

The problem is that I'm not able to find it.
Where is it? What are the names of the special procedures (I can't found
resume and detach in any ".h"-file)?

Does Stroustrup really means, that there is a possibilty to implement the
co-routine concept in C++, which is implemented e.g. in SIMULA?

Falko

bs@alice.UUCP (Bjarne Stroustrup) (10/13/88)

Look for task.h on the AT&T C++ shipping tape and for a paper by me called
``A Set of Classes for Co-routine Style Programming'' in the documentation.
The task system provides classes for Simula style event driven simulation.

lee@ssc-vax.UUCP (Lee Carver) (10/14/88)

In article <649@laura.UUCP>, bause@exunido.uucp (Falko Bause) writes:
> In an article from Bjarne Stroustrup 'What is "Object-Oriented Programming"?'
> 'For example, the C++ standard library provides a co-routine class.'
> 
> The problem is that I'm not able to find it.
> Where is it? What are the names of the special procedures (I can't found
> resume and detach in any ".h"-file)?
> 
> Does Stroustrup really means, that there is a possibilty to implement the
> co-routine concept in C++, which is implemented e.g. in SIMULA?

Strange, I had just been thinking on this issue, and maybe I can
muddy the waters some more :-).  It seems to me that an object, by
it self, of its very nature, constitues a co-routine.

Consider a program with communications between the objects.  Each
call on an object cause the called object to continue from its saved
(or suspended) state.  It seems that this is a complete
implementation of co-routines.

Am I missing some (archane :-) definition of "co-routine"ness.  Hope
this gets the discussion off to a good start.

lindsay@k.gp.cs.cmu.edu (Donald Lindsay) (10/15/88)

In article <1191@ssc-bee.ssc-vax.UUCP> lee@ssc-vax.UUCP (Lee Carver) writes:
>It seems to me that an object, by
>it self, of its very nature, constitues a co-routine.
>Am I missing some (archane :-) definition of "co-routine"ness.  


A coroutine should have a stack, so that when it resumes, it can 
- be anywhere in its code space (rather than at a single entry point)
- be at some procedure nesting level from the entry point
- still have the local variables it was using, without having
  to design them into the (relatively, global) data part of the object.
- be resumed in a utility routine which isn't conceptually part of the
  object (like, the IO system)

Yes, you can fake it, but the fakes lose most of the advantages.
-- 
Don		lindsay@k.gp.cs.cmu.edu    CMU Computer Science

raeder@uscacsc.usc.edu (Georg Raeder) (10/15/88)

In article <1191@ssc-bee.ssc-vax.UUCP>, lee@ssc-vax.UUCP (Lee Carver) writes:
> It seems to me that an object, by
> it self, of its very nature, constitues a co-routine.

Yes, this was the original and beautiful idea of SIMULA, but for some
reason it never made it to later languages.  To quote Bertrand Meyer, in
his recent book "Object-Oriented Software Construction":
   "Tony Hoare's remark about Algol 60 - that it was such an improvement
   over most of its successors - applies to Simula as well."

Georg Raeder, USC-ACSC, Los Angeles       raeder@cse.usc.edu