Index: doc/uC++toCFA/uC++toCFA.tex
===================================================================
--- doc/uC++toCFA/uC++toCFA.tex	(revision 8617ee90de06f87845137983052bf94f92299eff)
+++ doc/uC++toCFA/uC++toCFA.tex	(revision 567a75f3b6d1baf41c3bb74c76aa9b0ea6342ae8)
@@ -11,9 +11,8 @@
 %% Created On       : Wed Apr  6 14:53:29 2016
 %% Last Modified By : Peter A. Buhr
-%% Last Modified On : Sat Mar 15 13:38:53 2025
-%% Update Count     : 6302
+%% Last Modified On : Thu Aug 28 13:41:34 2025
+%% Update Count     : 6493
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
 
 \documentclass[11pt]{article}
@@ -83,4 +82,5 @@
 \setlength{\topmargin}{-0.45in}							% move running title into header
 \setlength{\headsep}{0.25in}
+\setlength{\tabcolsep}{15pt}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -134,5 +134,5 @@
 
 \maketitle
-\vspace*{-0.55in}
+\vspace*{-0.65in}
 
 \section{Introduction}
@@ -141,13 +141,23 @@
 \CFA uses parametric polymorphism and allows overloading of variables and routines:
 \begin{cfa}
-int i;  char i;  double i;	$\C[2in]{// overload name i}$
-int i();  double i();  char i();
-i += 1;						$\C{// int i}$
-i += 1.0;					$\C{// double i}$
-i += 'a'; 					$\C{// char i}$
-int j = i();				$\C{// int i()}$
-double j = i();				$\C{// double i();}$
-char j = i();				$\C{// char i()}\CRT$
-\end{cfa}
+int x;  char x;  double x;    // overload name x
+int x();  double x();  char x();
+\end{cfa}
+\vspace*{-8pt}
+\begin{cquote}
+\begin{tabular}{@{}l@{\hspace{1in}}|l@{}}
+\begin{cfa}
+x += 42;	$\C[1in]{// int x}$
+x += 42.2;	$\C{// double x}$
+x += 'a'; 	$\C{// char x}\CRT$
+\end{cfa}
+&
+\begin{cfa}
+int j = x();	$\C[1in]{// int x()}$
+double j = x();	$\C{// double x();}$
+char j = x();	$\C{// char x()}\CRT$
+\end{cfa}
+\end{tabular}
+\end{cquote}
 \CFA has rebindable references.
 \begin{cquote}
@@ -165,9 +175,9 @@
 &
 \begin{cfa}
-r2i = 3; $\C[1.0in]{// change x}$
+r2i = 3;	 $\C[0.875in]{// change x}$
 &r2i = &r1y; $\C{// change p2i / r2i}$
-r2i = 3; $\C{// change y}$
+r2i = 3;	 $\C{// change y}$
 &r1x = &r1y; $\C{// change p1x / r1x}$
-r2i = 4; $\C{// change y}$
+r2i = 4;	 $\C{// change y}$
 &r1x = @0p@; $\C{// reset}\CRT$
 \end{cfa}
@@ -194,29 +204,73 @@
 \end{cfa}
 \noindent
-In subsequent code examples, the left example is \uC and the right example is \CFA.
-
-
-\section{Looping}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-for ( @;;@ ) { ... }  /  while ( @true@ ) { ... }
+In subsequent code examples, the left example is \CC/\uC and the right example is \CFA.
+
+
+\section{Control Flow}
+
+The @choose@ statement provides an implicit @break@ after the @case@ clause for safety.
+It is possible to @break default@ in a @case@ clause to transfer to common code in the @default@ clause.
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+switch ( i ) {
+  case 1: ... @break@; // explicit break
+  case 2: ... @break@; // explicit break
+  default: ... ;
+}
+\end{uC++}
+&
+\begin{cfa}
+choose ( i ) {
+  case 1: ... ; // implicit break
+  case 2: ... ; // implicit break
+  default: ... ;
+}
+\end{cfa}
+\end{tabular}
+\end{cquote}
+To simplify creating an infinite loop, the loop condition in optional.
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+while ( true ) ...
+for ( ;; ) ...
+do ... while ( true )
+\end{uC++}
+&
+\begin{uC++}
+while ($\,$) ...
+for ($\,$) ...
+do ... while ($\,$)
+\end{uC++}
+\end{tabular}
+\end{cquote}
+To simplify loop iteration a range is provided, specified from low to high, and a traversal direction, ascending (@+@) or descending (@-@).
+The following is the syntax for the loop range, where @[@\,@]@ means optional.
+\begin{cfa}[deletekeywords=default]
+[ @index ;@ ] [ [ @min@ (default 0) ] [ direction @+@/@-@ (default +) ] @~@ [ @=@ (include endpoint) ] ] @max@ [ @~ increment@ ]
+\end{cfa}
+For @=@, the range includes the endpoint (@max@/@min@) depending on the direction (@+@/@-@).
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
 for ( int i = 0; i < @10@; i += 1 ) { ... }
 for ( int i = @5@; i < @15@; i += @2@ ) { ... }
-for ( int i = -1; i <@=@ 10; i += 3 ) { ... }
-for ( int i = 10; i > 0; i @-@= 1 ) { ... }
-\end{uC++}
-&
-\begin{cfa}
-for () { ... }  /  while () { ... }
-for ( @10@ ) { ... }  /  for ( i; @10@ ) { ... }
-for ( i; @5@ ~ @15@ ~ @2@ ) { ... }
-for ( i; -1 ~@=@ 10 ~ 3 ) { ... }
-for ( i; 0 @-@~ 10 ) { ... }
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
+for ( int i = -2; i <@=@ 10; i += 3 ) { ... }
+for ( int i = 10; i > -3; i @-@= 1 ) { ... }
+for ( int i = 10; i >@=@ 0; i @-@= 1 ) { ... }
+\end{uC++}
+&
+\begin{cfa}
+for ( @10@ ) { ... }  /  for ( i; @10@ ) { ... }  // 0 to 9 by 1
+for ( i; @5@ ~ @15@ ~ @2@ ) { ... } // 5 to 14 by 2
+for ( i; -2 ~@=@ 10 ~ 3 ) { ... } // -2 to 10 by 3
+for ( i; -3 @-@~ 10 ) { ... } // not 10 -~= -3, 10 to -2 by -1
+for ( i; 0 @-@~@=@ 10 ) { ... } // not 10 -~= 0, 10 to 0 by -1
+\end{cfa}
+\end{tabular}
+\end{cquote}
+A terminating loop @else@ (like Python) is executed if the loop terminates normally, \ie the loop conditional becomes false, which is safer than retesting after the loop.
+The loop index is available in the @else@ clause.
 \begin{cquote}
 \begin{tabular}{@{}l|l@{}}
@@ -230,85 +284,36 @@
 
 for ( i; 10 ) { ... }
-@else@ { ... } // i == 10
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
+@else@ { ... } // i == 10 because of post increment
+\end{cfa}
+\end{tabular}
+\end{cquote}
+Single/multiple-level loop exit/continue is provided by the labelled @break@/@continue@. (First example is \CC.)
+\begin{cquote}
+\begin{tabular}{@{}l|l|l@{}}
+\begin{C++}
 @L1:@ for ( ;; ) {
-	@L2:@ for ( ;; ) {
-		... if ( ... ) @break L1@; ...
-		... if ( ... ) @break L2@; ...
-	}
-}
-\end{uC++}
+	for ( ;; ) {
+		... if ( ... ) @goto L1@; ...
+		... if ( ... ) @goto L2@; ...
+	} @L2: ;@
+}
+\end{C++}
 &
 \begin{cfa}
 @L1:@ for () {
 	@L2:@ for () {
-		... if ( ... ) @break L1@; ...
+		... if ( ... ) @continue L1@; ...
 		... if ( ... ) @break L2@; ...
 	}
 }
 \end{cfa}
-\end{tabular}
-\end{cquote}
-
-
-\section{Stream I/O}
-
-\CFA output streams automatically separate values and insert a newline at the end of the print.
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-#include <@iostream@>
-using namespace std;
-int i;   double d;   char c;
-cin >> i >> d >> c;
-cout << i << ' ' << d << ' ' << c << endl;
-\end{uC++}
-&
-\begin{cfa}
-#include <@fstream.hfa@>
-
-int i;   double d;   char c;
-sin | i | d | c;
-sout | i | d | c
-\end{cfa}
-\end{tabular}
-\end{cquote}
-To disable/enable automatic newline at the end of printing, use @nlOff@/@nlOn@ and @nl@.
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-
-for ( int i = 0; i < 5; i += 1 ) cout << i << ' ';
-cout << @endl@;
-
-0 1 2 3 4 
-\end{uC++}
-&
-\begin{cfa}
-sout | @nlOff@; // disable auto nl
-for ( i; 5 ) sout | i;
-sout | @nl@;
-sout | @nlOn@;  // reenable auto nl
-0 1 2 3 4 
-\end{cfa}
-\end{tabular}
-\end{cquote}
-Floating-point numbers without a fraction print with a decimal point, which can be disabled with @nodp@.
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-cout << 3.0 << ' ' << showpoint << setprecision(0) << 3.0 << endl;
-3 3.
-\end{uC++}
-&
-\begin{cfa}
-sout | @nodp( 3.0 )@ | 3.0;
-3 3.
+&
+\begin{cfa}
+@L1:@ for () {
+	@L2:@ for () {
+		... if ( ... ) @continue L1@; ...
+		... if ( ... ) @break L2@; ...
+	}
+}
 \end{cfa}
 \end{tabular}
@@ -320,4 +325,5 @@
 Currently, \CFA uses macros @ExceptionDecl@ and @ExceptionInst@ to declare and instantiate an exception.
 \begin{cquote}
+\setlength{\tabcolsep}{5pt}
 \begin{tabular}{@{}l|ll@{}}
 \begin{uC++}
@@ -327,8 +333,6 @@
 };
 try {
-	...
-	if ( ... ) @_Resume@ E( /* initialization */ );
-	if ( ... ) @_Throw@ E( /* initialization */ );
-		...
+	... if ( ... ) @_Resume@ E( /* initialization */ ); ...
+	... if ( ... ) @_Throw@ E( /* initialization */ ); ...
 } @_CatchResume@( E & /* reference */ ) { ... }
   catch( E & ) { ... }
@@ -343,8 +347,6 @@
 );
 try {
-	...
-	if ( ... ) @throwResume@ @ExceptionInst@( E, /* intialization */ );
-	if ( ... ) @throw@ @ExceptionInst@( E, /* intialization */ );
-	...
+	... if ( ... ) @throwResume@ @ExceptionInst@( E, /* intialization */ ); ...
+	... if ( ... ) @throw@ @ExceptionInst@( E, /* intialization */ ); ...
 } @catchResume@( E @*@ /* pointer */ ) { ... }
   catch( E * ) { ... }
@@ -389,4 +391,182 @@
 
 
+\section{Stream I/O}
+
+\CFA output streams automatically separate values and insert a newline at the end of the print.
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+#include <@iostream@>
+using namespace std;
+int i;   double d;   char c;
+cin >> i >> d >> c;
+cout << i << ' ' << d << ' ' << c << endl;
+\end{uC++}
+&
+\begin{cfa}
+#include <@fstream.hfa@>
+
+int i;   double d;   char c;
+sin | i | d | c;
+sout | i | d | c
+\end{cfa}
+\end{tabular}
+\end{cquote}
+To disable/enable automatic newline at the end of printing, use @nlOff@/@nlOn@ and @nl@.
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+
+for ( int i = 0; i < 5; i += 1 ) cout << i << ' ';
+cout << @endl@;
+0 1 2 3 4 
+\end{uC++}
+&
+\begin{cfa}
+sout | @nlOff@; // disable auto nl
+for ( i; 5 ) sout | i;
+sout | @nl@; sout | @nlOn@;  // enable auto nl
+0 1 2 3 4 
+\end{cfa}
+\end{tabular}
+\end{cquote}
+Floating-point numbers without a fraction print with a decimal point, which can be disabled with @nodp@.
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+cout << 3.0 << ' ' << showpoint << setprecision(0) << 3.0 << endl;
+3 3.
+\end{uC++}
+&
+\begin{cfa}
+sout | @nodp( 3.0 )@ | 3.0;
+3 3.
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
+\section{String}
+
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\multicolumn{2}{@{}l@{}}{\lstinline{string s1, s2;}} \\
+\begin{uC++}
+s1 = "abcdefg";
+s2 = s1;
+s1 += s2;
+s1 == s2; s1 != s2;
+s1 < s2;  s1 <= s2;  s1 > s2;  s1 >= s2;
+s1.length();
+s1[3];
+s1.substr( 2 );  s1.substr( 2, 3 );
+s1.replace( 2, 5, s2 );
+s1.find( s2 );
+s1.find_first_of( "cd" );
+s1.find_first_not_of( "cd" );
+getline( cin, s1 );
+cout << s1 << endl;
+\end{uC++}
+&
+\begin{cfa}
+s1 = "abcdefg";
+s2 = s1;
+s1 += s2;
+s1 == s2; s1 != s2;
+s1 < s2;  s1 <= s2;  s1 > s2;  s1 >= s2;
+len( s1 );
+s1[3];
+s1( 2 );  s1( 2, 3 );
+s1( 2, 5 ) = s2;
+find( s1, s2 );
+exclude( s1, "cd" );  // longest sequence excluding "c" and "d"
+include( s1, "cd" );  // longest sequence including "c" and "d"
+sin | getline( s1 );
+sout | s1;
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
+\section{\texorpdfstring{\lstinline{uArray}}{uArray}}
+
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+#include <iostream>
+using namespace std;
+
+struct S {
+	int i;
+	S( int i ) { S::i = i; }
+};
+void f( uArrayRef( S, parm ) );
+int main() {
+	enum { N = 5 };
+	@uArray( S, s, N );@   // stack, no ctor calls
+	for ( int i = 0; i < N; i += 1 ) @s[i]( i )@; // ctor calls
+	for ( int i = 0; i < N; i += 1 ) cout << s[i]@->@i << endl;
+	f( s );
+	@uArrayPtr( S, sp, N );@   // heap, no ctor calls
+	for ( int i = 0; i < N; i += 1 ) @sp[i]( i )@; // ctor calls
+	for ( int i = 0; i < N; i += 1 ) cout << sp[i]@->@i << endl;
+	f( sp );
+} // delete s, sp
+\end{uC++}
+&
+\begin{cfa}
+#include <fstream.hfa>
+#include <array.hfa>
+#include <memory.hfa>
+struct S {
+	int i;
+};
+void ?{}( S & s, int i ) { s.i = i; }
+forall( [N] ) void f( array( S, N ) & parm ) {}
+int main() {
+	enum { N = 5 };
+	@array( S, N ) s = { delay_init };@ // no ctor calls
+	for ( i; N ) @s[i]{ i }@; // ctor calls
+	for ( i; N ) sout | s[i]@.@i;
+	f( s );
+    @unique_ptr( array( S, N ) )@ sp = { delay_init }; // heap
+    for ( int i = 0; i < N; i += 1 ) @(*sp)@[i]{ i }; // ctor calls
+    for ( int i = 0; i < N; i += 1 ) sout | @(*sp)@[i].i;
+	f( @*sp@ );
+} // delete s, sp
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
+\section{\texorpdfstring{Structures (object-oriented \protect\vs routine style)}{Structures (object-oriented vs. routine style)}}
+
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+struct S {
+	int i = 0;  // cheat, implicit default constructor
+	int setter( int j ) { int t = i; i = j; return t; }
+	int getter() { return i; }
+};
+S s;
+@s.@setter( 3 );  // object calls
+int k = @s.@getter();
+\end{uC++}
+&
+\begin{cfa}
+struct S {  int i;  };
+void ?{}( S & s ) { s.i = 0; } // explicit default constructor
+int setter( @S & s,@ int j ) @with( s )@ { int t = i; i = j; return t; }
+int getter( @S & s@ ) @with( s )@ { return i; }
+
+S s;
+setter( @s,@ 3 );  // normal calls
+int k = getter( @s@ );
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
 \section{Constructor / Destructor}
 
@@ -421,5 +601,5 @@
 void @?{}@( S & s ) { s.i = s.j = 3; } $\C[3in]{// default}$
 void @?{}@( S & s, int i, int j ) { s.i = i; s.j = j; } $\C{// initializer}$
-void @?{}@( S & s, const S rhs ) { s.[i,j] = rhs.[i,j]; } $\C{// copy}$
+void @?{}@( S & s, const S rhs ) { ?{}( s, rhs.i, rhs.j ); } $\C{// copy}$
 void @^?{}@( S & s ) { s.i = 0; s.j = 0; } $\C{// destructor}\CRT$
 
@@ -440,114 +620,4 @@
 
 
-\section{\texorpdfstring{Structures (object-oriented \protect\vs routine style)}{Structures (object-oriented vs. routine style)}}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-struct S {
-	int i = 0;  // cheat, implicit default constructor
-	int setter( int j ) { int t = i; i = j; return t; }
-	int getter() { return i; }
-};
-S s;
-@s.@setter( 3 );  // object calls
-int k = @s.@getter();
-\end{uC++}
-&
-\begin{cfa}
-struct S {  int i;  };
-void ?{}( S & s ) { s.i = 0; } // explicit default constructor
-int setter( @S & s,@ int j ) @with( s )@ { int t = i; i = j; return t; }
-int getter( @S & s@ ) @with( s )@ { return i; }
-
-S s;
-setter( @s,@ 3 );  // normal calls
-int k = getter( @s@ );
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
-
-\section{String}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\multicolumn{2}{@{}l@{}}{\lstinline{string s1, s2;}} \\
-\begin{uC++}
-s1 = "abcdefg";
-s2 = s1;
-s1 += s2;
-s1 == s2; s1 != s2;
-s1 < s2; s1 <= s2; s1 > s2; s1 >= s2;
-s1.length();
-s1[3];
-s1.substr( 2 ); s1.substr( 2, 3 );
-s1.replace( 2, 5, s2 );
-s1.find( s2 ); s1.rfind( s2 );
-s1.find_first_of( s2 ); s1.find_last_of( s2 );
-s1.find_first_not_of( s2 ); s1.find_last_not_of( s2 );
-getline( cin, s1 );
-cout << s1 << endl;
-\end{uC++}
-&
-\begin{cfa}
-s1 = "abcdefg";
-s2 = s1;
-s1 += s2;
-s1 == s2; s1 != s2;
-s1 < s2; s1 <= s2; s1 > s2; s1 >= s2;
-size( s1 );
-s1[3];
-s1( 2 ); s1( 2, 3 );
-// replace( s1, 2, 5, s2 );
-// find( s1, s2 ), rfind( s1, s2 );
-// find_first_of( s2 ); find_last_of( s2 );
-// find_first_not_of( s1, s2 ); find_last_not_of( s1, s2 );
-sin | getline( s1 );
-sout | s1;
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
-
-\section{\texorpdfstring{\lstinline{uArray}}{uArray}}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-#include <iostream>
-using namespace std;
-struct S {
-	int i;
-	S( int i ) { S::i = i; cout << "ctor " << S::i << endl; }
-	~S() { S::i = i; cout << "dtor " << S::i << endl; }
-};
-int main() {
-	enum { N = 5 };
-	@uArray( S, s, N );@   // no constructor calls
-	for ( int i = 0; i < N; i += 1 ) @s[i]( i )@; // constructor calls
-	for ( int i = 0; i < N; i += 1 ) cout << s[i]@->@i << endl;
-}
-\end{uC++}
-&
-\begin{cfa}
-#include <fstream.hfa>
-#include <array.hfa>
-struct S {
-	int i;
-};
-void ?{}( S & s, int i ) { s.i = i; sout | "ctor" | s.i; }
-void ^?{}( S & s ) { sout | "dtor" | s.i; }
-int main() {
-	enum { N = 5 };
-	@array( S, N ) s = { delay_init };@ // no constructor calls
-	for ( i; N ) @s[i]{ i }@; // constructor calls
-	for ( i; N ) sout | s[i]@.@i;
-}
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
-
 \section{Coroutine}
 
@@ -760,5 +830,5 @@
 #include <locks.hfa>
 owner_lock m;
-condition_variable( owner_lock ) s;  // generic type on mutex lock
+cond_lock( owner_lock ) s;  // generic type on mutex lock
 lock( m );
 if ( ! empty( s ) ) wait( s, m );
@@ -799,16 +869,4 @@
 enum { N = 3 };
 Barrier b{ N };
-
-_Task T {
-	void main() {
-		for ( int i = 0; i < 10; i += 1 ) {
-			b.block( 1 );
-		}
-	}
-};
-int main() {
-	uProcessor p[N - 1];
-	T t[N];
-}
 \end{uC++}
 &
@@ -836,16 +894,4 @@
 enum { N = 3 };
 Barrier b{ N };
-
-thread T {};
-void main( T & ) {
-	for ( 10 ) {
-		block( b, 1 );
-	}
-}
-
-int main() {
-	processor p[N - 1];
-	T t[N];
-}
 \end{cfa}
 \end{tabular}
