Index: doc/papers/concurrency/examples/Fib.cfa
===================================================================
--- doc/papers/concurrency/examples/Fib.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/Fib.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,72 @@
+#include <thread.hfa>
+#include <fstream.hfa>
+
+int fn1, fn2, state = 1;
+int fib_gvar() {
+	int fn;
+	choose ( state ) {
+	  case 1: fn = 0;  fn1 = fn;  state = 2;
+	  case 2: fn = 1;  fn2 = fn1;  fn1 = fn;  state = 3;
+	  case 3: fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;
+	}
+	return fn;
+}
+
+#define FIB_INIT { 0, 1 }
+typedef struct { int fn1, fn2; } Fib;
+int fib_state( Fib & f ) with( f ) {
+	int ret = fn2;
+	int fn = fn1 + fn2;
+	fn2 = fn1; fn1 = fn;
+	return ret;
+}
+
+coroutine Fib1 { int fn; };						// used for communication
+void main( Fib1 & fib ) with( fib ) {			// called on first resume
+	fn = 0;  int fn1 = fn; suspend();
+	fn = 1;  int fn2 = fn1;  fn1 = fn; suspend();
+	for () {
+		fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn; suspend();
+	}
+}
+int next( Fib1 & fib ) with( fib ) { resume( fib ); return fn; }
+
+coroutine Fib2 { int ret; };					// used for communication
+void main( Fib2 & fib ) with( fib ) {			// called on first resume
+	int fn, fn1 = 1, fn2 = 0;					// precompute first two states
+	for () {
+		ret = fn2;
+		fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;	// general case
+		suspend();								// restart last resume
+	}
+}
+int next( Fib2 & fib ) with( fib ) {
+	resume( fib );								// restart last suspend
+	return ret;
+}
+
+int main() {
+	for ( 10 )
+		sout | fib_gvar();
+	sout | nl;
+
+	Fib f1 = FIB_INIT, f2 = FIB_INIT;
+	for ( 10 )
+		sout | fib_state( f1 ) | fib_state( f2 );
+	sout | nl;
+
+	Fib1 f1, f2;
+	for ( 10 )
+		sout | next( f1 ) | next( f2 );
+	sout | nl;
+
+	Fib2 f1, f2;
+	for ( 10 )
+		sout | next( (Fib2 &)f1 ) | next( (Fib2 &)f2 );
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// fill-column: 120 //
+// compile-command: "cfa Fib.cfa" //
+// End: //
Index: doc/papers/concurrency/examples/Fib.py
===================================================================
--- doc/papers/concurrency/examples/Fib.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/Fib.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,17 @@
+def Fibonacci():
+	fn = 0;	fn1 = fn; yield fn  # suspend
+	fn = 1; fn2 = fn1; fn1 = fn; yield fn
+	while True:
+		fn = fn1 + fn2; fn2 = fn1; fn1 = fn; yield fn
+
+
+
+f1 = Fibonacci()
+f2 = Fibonacci()
+for i in range( 10 ):
+	print( next( f1 ), next( f2 ) )  # resume
+
+# Local Variables: #
+# tab-width: 4 #
+# compile-command: "python3.5 Fib.py" #
+# End: #
Index: doc/papers/concurrency/examples/Format.cfa
===================================================================
--- doc/papers/concurrency/examples/Format.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/Format.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,84 @@
+#if 1
+#include <fstream.hfa>
+#include <coroutine.hfa>
+
+coroutine Fmt {
+	char ch;								// communication variables
+	int g, b;								// needed in destructor
+};
+void main( Fmt & fmt ) with( fmt ) {
+	for () {								// for as many characters
+		for ( g = 0; g < 5; g += 1 ) {		// groups of 5 blocks
+			for ( b = 0; b < 4; b += 1 ) {	// blocks of 4 characters
+//				do {
+					suspend();
+//				} while ( ch == '\n' || ch == '\t' );
+				sout | ch;					// print character
+			}
+			sout | "  ";					// block separator
+		}
+		sout | nl;							// group separator
+	}
+}
+void ?{}( Fmt & fmt ) { resume( fmt ); } // prime (start) coroutine
+void ^?{}( Fmt & fmt ) with( fmt ) { // destructor
+	if ( g != 0 || b != 0 )	// special case
+		sout | nl; }
+void send( Fmt & fmt, char c ) { fmt.ch = c; resume( fmt ); }
+int main() {
+	Fmt fmt;
+ 	sout | nlOff;							// turn off auto newline
+	for ( 41 )
+		send( fmt, 'a' );
+  // 	sout | nlOff;							// turn off auto newline
+  // eof: for () {								// read until end of file
+  // 		sin | fmt.ch;						// read one character
+  // 	  if ( eof( sin ) ) break eof;			// eof ?
+  // 		format( fmt );						// push character for formatting
+  // 	}
+}
+#else
+
+#include <stdio.h>
+
+struct Format {
+	char ch;								// used for communication
+	int g, b;								// global because used in destructor
+};
+
+void format( struct Format * fmt ) {
+	if ( fmt->ch != -1 ) { // not EOF ?
+//		if ( fmt->ch == '\n' || fmt->ch == '\t' ) return;
+//		printf( "%c %d %d", fmt->ch, fmt->g, fmt->b );		// character
+		printf( "%c", fmt->ch );		// character
+		fmt->b += 1;
+		if ( fmt->b == 4 ) {	// block ?
+			printf( "  " ); // separator
+			fmt->b = 0;
+			fmt->g += 1;
+		}
+		if ( fmt->g == 5 ) {	// group ?
+			printf( "\n" ); // separator
+			fmt->g = 0;
+		}
+	} else {
+		if ( fmt->g != 0 || fmt->b != 0 ) printf( "\n" );
+	}
+}
+int main() {
+	struct Format fmt = { 0, 0, 0 };
+	for ( ;; ) {
+		scanf( "%c", &fmt.ch );
+	  if ( feof( stdin ) ) break;
+		format( &fmt );
+	}
+	fmt.ch = -1;
+	format( &fmt );
+}
+#endif
+
+// Local Variables: //
+// tab-width: 4 //
+// fill-column: 120 //
+// compile-command: "cfa Format.cfa" //
+// End: //
Index: doc/papers/concurrency/examples/Format.py
===================================================================
--- doc/papers/concurrency/examples/Format.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/Format.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,21 @@
+def Format():
+	try:
+		while True:
+			for g in range( 5 ): 	# groups of 5 blocks
+				for b in range( 4 ): # blocks of 4 characters
+					print( (yield), end='' ) # receive from send
+				print( '  ', end='' ) # block separator
+			print()					# group separator
+	except GeneratorExit:			# destructor
+		if g != 0 | b != 0:			# special case
+			print()
+
+fmt = Format()
+next( fmt )							# prime generator
+for i in range( 41 ):
+	fmt.send( 'a' );				# send to yield
+
+# Local Variables: #
+# tab-width: 4 #
+# compile-command: "python3.5 Format.py" #
+# End: #
Index: doc/papers/concurrency/examples/ProdCons.cfa
===================================================================
--- doc/papers/concurrency/examples/ProdCons.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/ProdCons.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,77 @@
+#include <fstream.hfa>
+#include <coroutine.hfa>
+#include <stdlib.hfa>									// random
+#include <unistd.h>										// getpid
+coroutine Cons;											// forward
+int delivery( Cons & cons, int p1, int p2 );
+void stop( Cons & cons );
+
+coroutine Prod {
+	Cons & c;
+	int N, money, receipt;
+};
+void main( Prod & prod ) with( prod ) {					// starter ::main
+	// 1st resume starts here
+	for ( i; N ) {										// N pairs of values
+		int p1 = random( 100 ), p2 = random( 100 );
+		sout | p1 | " " | p2;
+		int status = delivery( c, p1, p2 );
+		sout | " $" | money | nl | status;
+		receipt += 1;
+	}
+	stop( c );
+	sout | "prod stops";
+}
+int payment( Prod & prod, int money ) {
+	prod.money = money;
+	resume( prod );										// main 1st time, then
+	return prod.receipt;								// prod in delivery
+}
+void start( Prod & prod, int N, Cons &c ) {
+	&prod.c = &c;
+	prod.[N, receipt] = [N, 0];
+	resume( prod );										// activate main
+}
+coroutine Cons {
+	Prod & p;
+	int p1, p2, status;
+	bool done;
+};
+void ?{}( Cons & cons, Prod & p ) {
+	&cons.p = &p;
+	cons.[status, done ] = [0, false];
+}
+void ^?{}( Cons & cons ) {}
+void main( Cons & cons ) with( cons ) {					// starter prod
+	// 1st resume starts here
+	int money = 1, receipt;
+	for ( ; ! done; ) {
+		sout | p1 | " " | p2 | nl | " $" | money;
+		status += 1;
+		receipt = payment( p, money );
+		sout | " #" | receipt;
+		money += 1;
+	}
+	sout | "cons stops";
+}
+int delivery( Cons & cons, int p1, int p2 ) {
+	cons.[p1, p2] = [p1, p2];
+	resume( cons );										// main 1st time, then
+	return cons.status;									// cons in payment
+}
+void stop( Cons & cons ) {
+	cons.done = true;
+	resume( cons );										// activate payment
+}
+int main() {
+	Prod prod;
+	Cons cons = { prod };
+	srandom( getpid() );
+	start( prod, 5, cons );
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// fill-column: 120 //
+// compile-command: "cfa ProdCons.c" //
+// End: //
Index: doc/papers/concurrency/examples/pingpong.py
===================================================================
--- doc/papers/concurrency/examples/pingpong.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
+++ doc/papers/concurrency/examples/pingpong.py	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -0,0 +1,26 @@
+i = 0
+def pong():
+	global i
+	print( "pong" )
+	if i < 4:
+		yield from ping()
+	print( "stop pong" )
+
+def ping():
+	global i
+	print( "ping" )
+	i += 1
+	if i < 5:
+		yield from pong()
+	print( "stop ping" )
+
+p = ping()
+try:
+	next( p )
+except StopIteration:
+	print( "stop" )
+
+# Local Variables: #
+# tab-width: 4 #
+# compile-command: "python3.5 pingpong.py" #
+# End: #
Index: tests/coroutine/devicedriver.cfa
===================================================================
--- tests/coroutine/devicedriver.cfa	(revision be3416ddba79f884d9277e46720fed68f698c5dd)
+++ tests/coroutine/devicedriver.cfa	(revision 81a05ca7b95019010a1ac2abbb946d9aa445b283)
@@ -10,6 +10,6 @@
 // Created On       : Sat Mar 16 15:30:34 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Mar 18 08:29:20 2019
-// Update Count     : 79
+// Last Modified On : Tue Mar 19 15:59:06 2019
+// Update Count     : 87
 // 
 
@@ -28,7 +28,14 @@
 } // next
 
+void checkCRC( Driver & d, unsigned int sum ) with( d ) {
+	suspend();
+	unsigned short int crc = byte << 8;					// sign extension over written
+	suspend();
+	// prevent sign extension for signed char
+	status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
+} // checkCRC
+
 void main( Driver & d ) with( d ) {
 	enum { STX = '\002', ESC = '\033', ETX = '\003', MaxMsg = 64 };
-	unsigned short int crc;								// error checking
   msg: for () {											// parse message
 		status = CONT;
@@ -52,8 +59,5 @@
 		} // for
 		msg[lnth] = '\0';								// terminate string
-		suspend();
-		crc = (unsigned char)byte << 8;	// prevent sign extension for signed char
-		suspend();
-		status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
+		checkCRC( d, sum );								// refactor CRC check
 		suspend();
 	} // for
