Index: libcfa/prelude/builtins.c
===================================================================
--- libcfa/prelude/builtins.c	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/prelude/builtins.c	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Fri Jul 21 16:21:03 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Aug 14 08:45:54 2021
-// Update Count     : 133
+// Last Modified On : Thu Feb  2 11:33:56 2023
+// Update Count     : 135
 //
 
@@ -64,5 +64,6 @@
 static inline void ^?{}(generator$ &) {}
 
-trait is_generator(T &) {
+forall( T & )
+trait is_generator {
       void main(T & this);
       generator$ * get_generator(T & this);
Index: libcfa/prelude/prelude-gen.cc
===================================================================
--- libcfa/prelude/prelude-gen.cc	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/prelude/prelude-gen.cc	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Sat Feb 16 08:44:58 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Apr  2 17:18:24 2019
-// Update Count     : 37
+// Last Modified On : Thu Feb  2 11:40:01 2023
+// Update Count     : 38
 //
 
@@ -159,5 +159,5 @@
 int main() {
 	cout << "# 2 \"prelude.cfa\"  // needed for error messages from this file" << endl;
-	cout << "trait sized(T &) {};" << endl;
+	cout << "forall( T & ) trait sized {};" << endl;
 
 	cout << "//////////////////////////" << endl;
Index: libcfa/src/bits/containers.hfa
===================================================================
--- libcfa/src/bits/containers.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/bits/containers.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Tue Oct 31 16:38:50 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jan 15 07:42:35 2020
-// Update Count     : 28
+// Last Modified On : Thu Feb  2 11:33:08 2023
+// Update Count     : 29
 
 #pragma once
@@ -69,5 +69,6 @@
 
 #ifdef __cforall
-	trait is_node(T &) {
+	forall( T & )
+	trait is_node {
 		T *& get_next( T & );
 	};
Index: libcfa/src/concurrency/actor.hfa
===================================================================
--- libcfa/src/concurrency/actor.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/actor.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -1,5 +1,8 @@
+#pragma once
+
 #include <locks.hfa>
 #include <limits.hfa>
 #include <list.hfa>
+#include <kernel.hfa>
 
 #ifdef __CFA_DEBUG__
@@ -21,4 +24,7 @@
 // Define if executor is created in a separate cluster
 #define __DEFAULT_EXECUTOR_SEPCLUS__ false
+
+// when you flip this make sure to recompile compiler and flip the appropriate flag there too in Actors.cpp
+#define __ALLOC 0
 
 // forward decls
@@ -38,6 +44,6 @@
 P9_EMBEDDED( request, dlink(request) )
 
-void ?{}( request & this ) { this.stop = true; } // default ctor makes a sentinel
-void ?{}( request & this, actor * receiver, message * msg, __receive_fn fn ) {
+static inline void ?{}( request & this ) { this.stop = true; } // default ctor makes a sentinel
+static inline void ?{}( request & this, actor * receiver, message * msg, __receive_fn fn ) {
     this.receiver = receiver;
     this.msg = msg;
@@ -45,38 +51,109 @@
     this.stop = false;
 }
-
+static inline void ?{}( request & this, request & copy ) {
+    this.receiver = copy.receiver;
+    this.msg = copy.msg;
+    this.fn = copy.fn;
+    this.stop = copy.stop;
+}
+
+// hybrid data structure. Copies until buffer is full and then allocates for intrusive list
+struct copy_queue {
+    dlist( request ) list;
+    #if ! __ALLOC
+    request * buffer;
+    size_t count, buffer_size, index;
+    #endif
+};
+static inline void ?{}( copy_queue & this ) {}
+static inline void ?{}( copy_queue & this, size_t buf_size ) with(this) { 
+    list{};
+    #if ! __ALLOC
+    buffer_size = buf_size;
+    buffer = aalloc( buffer_size );
+    count = 0;
+    index = 0;
+    #endif
+}
+static inline void ^?{}( copy_queue & this ) with(this) {
+    #if ! __ALLOC
+    adelete(buffer);
+    #endif
+}
+
+static inline void insert( copy_queue & this, request & elem ) with(this) {
+    #if ! __ALLOC
+    if ( count < buffer_size ) { // fast path ( no alloc )
+        buffer[count]{ elem };
+        count++;
+        return;
+    }
+    request * new_elem = alloc();
+    (*new_elem){ elem };
+    insert_last( list, *new_elem );
+    #else
+    insert_last( list, elem );
+    #endif
+}
+
+// once you start removing you need to remove all elements
+// it is not supported to call insert() before the list is fully empty
+// should_delete is an output param
+static inline request & remove( copy_queue & this, bool & should_delete ) with(this) {
+    #if ! __ALLOC
+    if ( count > 0 ) {
+        count--;
+        should_delete = false;
+        size_t old_idx = index;
+        index = count == 0 ? 0 : index + 1;
+        return buffer[old_idx];
+    }
+    #endif
+    should_delete = true;
+    return try_pop_front( list );
+}
+
+static inline bool isEmpty( copy_queue & this ) with(this) {
+    #if ! __ALLOC
+    return count == 0 && list`isEmpty;
+    #else
+    return list`isEmpty;
+    #endif
+}
+
+static size_t __buffer_size = 10; // C_TODO: rework this to be passed from executor through ctors (no need for global)
 struct work_queue {
-    futex_mutex mutex_lock; 
-    dlist( request ) input;						// unbounded list of work requests
+    __spinlock_t mutex_lock;
+    copy_queue owned_queue;
+    copy_queue * c_queue; // C_TODO: try putting this on the stack with ptr juggling
+
 }; // work_queue
-void ?{}( work_queue & this ) with(this) { input{}; mutex_lock{}; }
-
-void insert( work_queue & this, request & elem ) with(this) {
-    lock( mutex_lock );
-    insert_last( input, elem );
+static inline void ?{}( work_queue & this ) with(this) { 
+    // c_queue = alloc();
+    // (*c_queue){ __buffer_size };
+    owned_queue{ __buffer_size };
+    c_queue = &owned_queue;
+}
+// static inline void ^?{}( work_queue & this ) with(this) { delete( c_queue ); }
+
+static inline void insert( work_queue & this, request & elem ) with(this) {
+    lock( mutex_lock __cfaabi_dbg_ctx2 );
+    insert( *c_queue, elem );
     unlock( mutex_lock );
 } // insert
 
-void transfer( work_queue & this, dlist(request) & transferTo ) with(this) {
-    lock( mutex_lock );
-
-    //C_TODO CHANGE
-    // transferTo->transfer( input );              // transfer input to output
-
-    // this is awfully inefficient but Ill use it until transfer is implemented
-    request * r;
-    while ( ! input`isEmpty ) {
-        r = &try_pop_front( input );
-        if ( r ) insert_last( transferTo, *r );
-    }
-
-    // transfer( input, transferTo );
-
+static inline void transfer( work_queue & this, copy_queue ** transfer_to ) with(this) {
+    lock( mutex_lock __cfaabi_dbg_ctx2 );
+    // swap copy queue ptrs
+    copy_queue * temp = *transfer_to;
+    *transfer_to = c_queue;
+    c_queue = temp;
     unlock( mutex_lock );
 } // transfer
 
 thread worker {
+    copy_queue owned_queue;
     work_queue * request_queues;
-    dlist( request ) current_queue;
+    copy_queue * current_queue;
 	request & req;
     unsigned int start, range;
@@ -86,8 +163,12 @@
     ((thread &)this){ clu };
     this.request_queues = request_queues;
-    this.current_queue{};
+    // this.current_queue = alloc();
+    // (*this.current_queue){ __buffer_size };
+    this.owned_queue{ __buffer_size };
+    this.current_queue = &this.owned_queue;
     this.start = start;
     this.range = range;
 }
+// static inline void ^?{}( worker & mutex this ) with(this) { delete( current_queue ); }
 
 struct executor {
@@ -100,6 +181,7 @@
 }; // executor
 
-static inline void ?{}( executor & this, unsigned int nprocessors, unsigned int nworkers, unsigned int nrqueues, bool seperate_clus ) with(this) {
+static inline void ?{}( executor & this, unsigned int nprocessors, unsigned int nworkers, unsigned int nrqueues, bool seperate_clus, size_t buf_size ) with(this) {
     if ( nrqueues < nworkers ) abort( "nrqueues needs to be >= nworkers\n" );
+    __buffer_size = buf_size;
     this.nprocessors = nprocessors;
     this.nworkers = nworkers;
@@ -127,5 +209,5 @@
     } // for
 }
-
+static inline void ?{}( executor & this, unsigned int nprocessors, unsigned int nworkers, unsigned int nrqueues, bool seperate_clus ) { this{ nprocessors, nworkers, nrqueues, seperate_clus, __buffer_size }; }
 static inline void ?{}( executor & this, unsigned int nprocessors, unsigned int nworkers, unsigned int nrqueues ) { this{ nprocessors, nworkers, nrqueues, __DEFAULT_EXECUTOR_SEPCLUS__ }; }
 static inline void ?{}( executor & this, unsigned int nprocessors, unsigned int nworkers ) { this{ nprocessors, nworkers, __DEFAULT_EXECUTOR_RQUEUES__ }; }
@@ -147,7 +229,7 @@
     } // for
 
-    delete( workers );
-    delete( request_queues );
-    delete( processors );
+    adelete( workers );
+    adelete( request_queues );
+    adelete( processors );
     if ( seperate_clus ) delete( cluster );
 }
@@ -170,5 +252,5 @@
 };
 
-void ?{}( actor & this ) {
+static inline void ?{}( actor & this ) {
     // Once an actor is allocated it must be sent a message or the actor system cannot stop. Hence, its receive
     // member must be called to end it
@@ -178,5 +260,5 @@
     __atomic_fetch_add( &__num_actors_, 1, __ATOMIC_SEQ_CST );
 }
-void ^?{}( actor & this ) {}
+static inline void ^?{}( actor & this ) {}
 
 static inline void check_actor( actor & this ) {
@@ -204,7 +286,7 @@
 };
 
-void ?{}( message & this ) { this.allocation_ = Nodelete; }
-void ?{}( message & this, Allocation allocation ) { this.allocation_ = allocation; }
-void ^?{}( message & this ) {}
+static inline void ?{}( message & this ) { this.allocation_ = Nodelete; }
+static inline void ?{}( message & this, Allocation allocation ) { this.allocation_ = allocation; }
+static inline void ^?{}( message & this ) {}
 
 static inline void check_message( message & this ) {
@@ -217,5 +299,5 @@
 }
 
-void deliver_request( request & this ) {
+static inline void deliver_request( request & this ) {
     Allocation actor_allocation = this.fn( *this.receiver, *this.msg );
     this.receiver->allocation_ = actor_allocation;
@@ -225,14 +307,16 @@
 
 void main( worker & this ) with(this) {
+    bool should_delete;
     Exit:
     for ( unsigned int i = 0;; i = (i + 1) % range ) { // cycle through set of request buffers
-        transfer( request_queues[i + start], current_queue );
-        while ( ! current_queue`isEmpty ) {
-            &req = &try_pop_front( current_queue );
+        // C_TODO: potentially check queue count instead of immediately trying to transfer
+        transfer( request_queues[i + start], &current_queue );
+        while ( ! isEmpty( *current_queue ) ) {
+            &req = &remove( *current_queue, should_delete );
             if ( !&req ) continue; // possibly add some work stealing/idle sleep here
             if ( req.stop ) break Exit;
             deliver_request( req );
 
-            delete( &req );
+            if ( should_delete ) delete( &req );
         } // while
     } // for
@@ -250,5 +334,5 @@
     __actor_executor_thd = active_thread();
     __actor_executor_ = alloc();
-    (*__actor_executor_){ 0, num_thds, num_thds * 16 };
+    (*__actor_executor_){ 0, num_thds, num_thds == 1 ? 1 : num_thds * 16 };
 }
 
Index: libcfa/src/concurrency/coroutine.hfa
===================================================================
--- libcfa/src/concurrency/coroutine.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/coroutine.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Mon Nov 28 12:27:26 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jan  6 16:33:16 2022
-// Update Count     : 12
+// Last Modified On : Thu Feb  2 11:31:42 2023
+// Update Count     : 13
 //
 
@@ -38,5 +38,6 @@
 // Anything that implements this trait can be resumed.
 // Anything that is resumed is a coroutine.
-trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) {
+forall( T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T)) )
+trait is_coroutine {
 	void main(T & this);
 	coroutine$ * get_coroutine(T & this);
Index: libcfa/src/concurrency/locks.hfa
===================================================================
--- libcfa/src/concurrency/locks.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/locks.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -640,5 +640,6 @@
 //-----------------------------------------------------------------------------
 // is_blocking_lock
-trait is_blocking_lock(L & | sized(L)) {
+forall( L & | sized(L) )
+trait is_blocking_lock {
 	// For synchronization locks to use when acquiring
 	void on_notify( L &, struct thread$ * );
Index: libcfa/src/concurrency/monitor.hfa
===================================================================
--- libcfa/src/concurrency/monitor.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/monitor.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Thd Feb 23 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Dec  4 07:55:32 2019
-// Update Count     : 11
+// Last Modified On : Thu Feb  2 11:29:21 2023
+// Update Count     : 12
 //
 
@@ -22,5 +22,6 @@
 #include "stdlib.hfa"
 
-trait is_monitor(T &) {
+forall( T & )
+trait is_monitor {
 	monitor$ * get_monitor( T & );
 	void ^?{}( T & mutex );
Index: libcfa/src/concurrency/mutex.hfa
===================================================================
--- libcfa/src/concurrency/mutex.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/mutex.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -12,6 +12,6 @@
 // Created On       : Fri May 25 01:24:09 2018
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Dec  4 09:16:53 2019
-// Update Count     : 1
+// Last Modified On : Thu Feb  2 11:46:08 2023
+// Update Count     : 2
 //
 
@@ -70,5 +70,6 @@
 void unlock(recursive_mutex_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
 
-trait is_lock(L & | sized(L)) {
+forall( L & | sized(L) )
+trait is_lock {
 	void lock  (L &);
 	void unlock(L &);
Index: libcfa/src/concurrency/thread.hfa
===================================================================
--- libcfa/src/concurrency/thread.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/concurrency/thread.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Nov 22 22:18:34 2022
-// Update Count     : 35
+// Last Modified On : Thu Feb  2 11:27:59 2023
+// Update Count     : 37
 //
 
@@ -27,5 +27,6 @@
 //-----------------------------------------------------------------------------
 // thread trait
-trait is_thread(T &) {
+forall( T & )
+trait is_thread {
 	void ^?{}(T& mutex this);
 	void main(T& this);
Index: libcfa/src/containers/list.hfa
===================================================================
--- libcfa/src/containers/list.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/containers/list.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -9,7 +9,7 @@
 // Author           : Michael Brooks
 // Created On       : Wed Apr 22 18:00:00 2020
-// Last Modified By : Michael Brooks
-// Last Modified On : Wed Apr 22 18:00:00 2020
-// Update Count     : 1
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Feb  2 11:32:26 2023
+// Update Count     : 2
 //
 
@@ -23,5 +23,6 @@
 };
 
-trait embedded( tOuter &, tMid &, tInner & ) {
+forall( tOuter &, tMid &, tInner & )
+trait embedded {
     tytagref( tMid, tInner ) ?`inner( tOuter & );
 };
Index: libcfa/src/containers/vector.hfa
===================================================================
--- libcfa/src/containers/vector.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/containers/vector.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jul  5 18:00:07 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jun 17 11:02:46 2020
-// Update Count     : 4
+// Last Modified On : Thu Feb  2 11:41:24 2023
+// Update Count     : 5
 //
 
@@ -50,6 +50,6 @@
 //------------------------------------------------------------------------------
 //Declaration
-trait allocator_c(T, allocator_t)
-{
+forall( T, allocator_t )
+trait allocator_c {
 	void realloc_storage(allocator_t*, size_t);
 	T* data(allocator_t*);
Index: libcfa/src/exception.h
===================================================================
--- libcfa/src/exception.h	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/exception.h	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -9,7 +9,7 @@
 // Author           : Andrew Beach
 // Created On       : Mon Jun 26 15:11:00 2017
-// Last Modified By : Andrew Beach
-// Last Modified On : Thr Apr  8 15:20:00 2021
-// Update Count     : 12
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Feb  2 11:20:19 2023
+// Update Count     : 13
 //
 
@@ -101,5 +101,6 @@
 // implemented in the .c file either so they all have to be inline.
 
-trait is_exception(exceptT &, virtualT &) {
+forall( exceptT &, virtualT & )
+trait is_exception {
 	/* The first field must be a pointer to a virtual table.
 	 * That virtual table must be a decendent of the base exception virtual table.
@@ -109,9 +110,11 @@
 };
 
-trait is_termination_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) {
+forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) )
+trait is_termination_exception {
 	void defaultTerminationHandler(exceptT &);
 };
 
-trait is_resumption_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) {
+forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) )
+trait is_resumption_exception {
 	void defaultResumptionHandler(exceptT &);
 };
Index: libcfa/src/iostream.hfa
===================================================================
--- libcfa/src/iostream.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/iostream.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Oct 10 10:02:07 2021
-// Update Count     : 407
+// Last Modified On : Thu Feb  2 11:25:39 2023
+// Update Count     : 410
 //
 
@@ -22,5 +22,6 @@
 
 
-trait basic_ostream( ostype & ) {
+forall( ostype & )
+trait basic_ostream {
 	// private
 	bool sepPrt$( ostype & );							// get separator state (on/off)
@@ -51,5 +52,6 @@
 }; // basic_ostream
 	
-trait ostream( ostype & | basic_ostream( ostype ) ) {
+forall( ostype & | basic_ostream( ostype ) )
+trait ostream {
 	bool fail( ostype & );								// operation failed?
 	void clear( ostype & );
@@ -60,9 +62,11 @@
 }; // ostream
 
-// trait writeable( T ) {
+// forall( T )
+// trait writeable {
 // 	forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T );
 // }; // writeable
 
-trait writeable( T, ostype & | ostream( ostype ) ) {
+forall( T, ostype & | ostream( ostype ) )
+	trait writeable {
 	ostype & ?|?( ostype &, T );
 }; // writeable
@@ -290,5 +294,6 @@
 
 
-trait basic_istream( istype & ) {
+forall( istype & )
+trait basic_istream {
 	// private
 	bool getANL$( istype & );							// get scan newline (on/off)
@@ -302,5 +307,6 @@
 }; // basic_istream
 
-trait istream( istype & | basic_istream( istype ) ) {
+forall( istype & | basic_istream( istype ) )
+trait istream {
 	bool fail( istype & );
 	void clear( istype & );
@@ -310,5 +316,6 @@
 }; // istream
 
-trait readable( T ) {
+forall( T )
+trait readable {
 	forall( istype & | istream( istype ) ) istype & ?|?( istype &, T );
 }; // readable
Index: libcfa/src/iterator.hfa
===================================================================
--- libcfa/src/iterator.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/iterator.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul  7 08:37:25 2017
-// Update Count     : 10
+// Last Modified On : Thu Feb  2 11:21:50 2023
+// Update Count     : 11
 //
 
@@ -17,5 +17,6 @@
 
 // An iterator can be used to traverse a data structure.
-trait iterator( iterator_type, elt_type ) {
+forall( iterator_type, elt_type )
+trait iterator {
 	// point to the next element
 //	iterator_type ?++( iterator_type & );
@@ -31,5 +32,6 @@
 };
 
-trait iterator_for( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) {
+forall( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) )
+	trait iterator_for {
 //	[ iterator_type begin, iterator_type end ] get_iterators( collection_type );
 	iterator_type begin( collection_type );
Index: libcfa/src/math.trait.hfa
===================================================================
--- libcfa/src/math.trait.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/math.trait.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,21 +10,24 @@
 // Created On       : Fri Jul 16 15:40:52 2021
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jul 20 17:47:19 2021
-// Update Count     : 19
+// Last Modified On : Thu Feb  2 11:36:56 2023
+// Update Count     : 20
 // 
 
 #pragma once
 
-trait Not( U ) {
+forall( U )
+trait Not {
 	void ?{}( U &, zero_t );
 	int !?( U );
 }; // Not
 
-trait Equality( T | Not( T ) ) {
+forall( T | Not( T ) )
+trait Equality {
 	int ?==?( T, T );
 	int ?!=?( T, T );
 }; // Equality
 
-trait Relational( U | Equality( U ) ) {
+forall( U | Equality( U ) )
+trait Relational {
 	int ?<?( U, U );
 	int ?<=?( U, U );
@@ -33,5 +36,6 @@
 }; // Relational
 
-trait Signed( T ) {
+forall ( T )
+trait Signed {
 	T +?( T );
 	T -?( T );
@@ -39,5 +43,6 @@
 }; // Signed
 
-trait Additive( U | Signed( U ) ) {
+forall( U | Signed( U ) )
+trait Additive {
 	U ?+?( U, U );
 	U ?-?( U, U );
@@ -46,5 +51,6 @@
 }; // Additive
 
-trait Incdec( T | Additive( T ) ) {
+forall( T | Additive( T ) )
+trait Incdec {
 	void ?{}( T &, one_t );
 	// T ?++( T & );
@@ -54,5 +60,6 @@
 }; // Incdec
 
-trait Multiplicative( U | Incdec( U ) ) {
+forall( U | Incdec( U ) )
+trait Multiplicative {
 	U ?*?( U, U );
 	U ?/?( U, U );
@@ -61,5 +68,6 @@
 }; // Multiplicative
 
-trait Arithmetic( T | Relational( T ) | Multiplicative( T ) ) {
+forall( T | Relational( T ) | Multiplicative( T ) )
+trait Arithmetic {
 }; // Arithmetic
 
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ libcfa/src/stdlib.hfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Dec 11 18:25:53 2022
-// Update Count     : 765
+// Last Modified On : Thu Feb  2 11:30:04 2023
+// Update Count     : 766
 //
 
@@ -404,5 +404,6 @@
 //   calls( sprng );
 
-trait basic_prng( PRNG &, R ) {
+forall( PRNG &, R )
+trait basic_prng {
 	void set_seed( PRNG & prng, R seed );				// set seed
 	R get_seed( PRNG & prng );							// get seed
Index: src/Common/ScopedMap.h
===================================================================
--- src/Common/ScopedMap.h	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/Common/ScopedMap.h	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -37,5 +37,5 @@
 		template<typename N>
 		Scope(N && n) : map(), note(std::forward<N>(n)) {}
-		
+
 		Scope() = default;
 		Scope(const Scope &) = default;
@@ -46,5 +46,6 @@
 	typedef std::vector< Scope > ScopeList;
 
-	ScopeList scopes; ///< scoped list of maps
+	/// Scoped list of maps.
+	ScopeList scopes;
 public:
 	typedef typename MapType::key_type key_type;
@@ -58,158 +59,7 @@
 	typedef typename MapType::const_pointer const_pointer;
 
-	class iterator : public std::iterator< std::bidirectional_iterator_tag, value_type > {
-	friend class ScopedMap;
-	friend class const_iterator;
-		typedef typename ScopedMap::MapType::iterator wrapped_iterator;
-		typedef typename ScopedMap::ScopeList scope_list;
-		typedef typename scope_list::size_type size_type;
-
-		/// Checks if this iterator points to a valid item
-		bool is_valid() const {
-			return it != (*scopes)[level].map.end();
-		}
-
-		/// Increments on invalid
-		iterator & next_valid() {
-			if ( ! is_valid() ) { ++(*this); }
-			return *this;
-		}
-
-		/// Decrements on invalid
-		iterator & prev_valid() {
-			if ( ! is_valid() ) { --(*this); }
-			return *this;
-		}
-
-		iterator(scope_list & _scopes, const wrapped_iterator & _it, size_type inLevel)
-			: scopes(&_scopes), it(_it), level(inLevel) {}
-	public:
-		iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
-		iterator & operator= (const iterator & that) {
-			scopes = that.scopes; level = that.level; it = that.it;
-			return *this;
-		}
-
-		reference operator* () { return *it; }
-		pointer operator-> () const { return it.operator->(); }
-
-		iterator & operator++ () {
-			if ( it == (*scopes)[level].map.end() ) {
-				if ( level == 0 ) return *this;
-				--level;
-				it = (*scopes)[level].map.begin();
-			} else {
-				++it;
-			}
-			return next_valid();
-		}
-		iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; }
-
-		iterator & operator-- () {
-			// may fail if this is the begin iterator; allowed by STL spec
-			if ( it == (*scopes)[level].map.begin() ) {
-				++level;
-				it = (*scopes)[level].map.end();
-			}
-			--it;
-			return prev_valid();
-		}
-		iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; }
-
-		bool operator== (const iterator & that) const {
-			return scopes == that.scopes && level == that.level && it == that.it;
-		}
-		bool operator!= (const iterator & that) const { return !( *this == that ); }
-
-		size_type get_level() const { return level; }
-
-		Note & get_note() { return (*scopes)[level].note; }
-		const Note & get_note() const { return (*scopes)[level].note; }
-
-	private:
-		scope_list *scopes;
-		wrapped_iterator it;
-		size_type level;
-	};
-
-	class const_iterator : public std::iterator< std::bidirectional_iterator_tag,
-	                                             value_type > {
-	friend class ScopedMap;
-		typedef typename ScopedMap::MapType::iterator wrapped_iterator;
-		typedef typename ScopedMap::MapType::const_iterator wrapped_const_iterator;
-		typedef typename ScopedMap::ScopeList scope_list;
-		typedef typename scope_list::size_type size_type;
-
-		/// Checks if this iterator points to a valid item
-		bool is_valid() const {
-			return it != (*scopes)[level].map.end();
-		}
-
-		/// Increments on invalid
-		const_iterator & next_valid() {
-			if ( ! is_valid() ) { ++(*this); }
-			return *this;
-		}
-
-		/// Decrements on invalid
-		const_iterator & prev_valid() {
-			if ( ! is_valid() ) { --(*this); }
-			return *this;
-		}
-
-		const_iterator(scope_list const & _scopes, const wrapped_const_iterator & _it, size_type inLevel)
-			: scopes(&_scopes), it(_it), level(inLevel) {}
-	public:
-		const_iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
-		const_iterator(const const_iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
-		const_iterator & operator= (const iterator & that) {
-			scopes = that.scopes; level = that.level; it = that.it;
-			return *this;
-		}
-		const_iterator & operator= (const const_iterator & that) {
-			scopes = that.scopes; level = that.level; it = that.it;
-			return *this;
-		}
-
-		const_reference operator* () { return *it; }
-		const_pointer operator-> () { return it.operator->(); }
-
-		const_iterator & operator++ () {
-			if ( it == (*scopes)[level].map.end() ) {
-				if ( level == 0 ) return *this;
-				--level;
-				it = (*scopes)[level].map.begin();
-			} else {
-				++it;
-			}
-			return next_valid();
-		}
-		const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; }
-
-		const_iterator & operator-- () {
-			// may fail if this is the begin iterator; allowed by STL spec
-			if ( it == (*scopes)[level].map.begin() ) {
-				++level;
-				it = (*scopes)[level].map.end();
-			}
-			--it;
-			return prev_valid();
-		}
-		const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; }
-
-		bool operator== (const const_iterator & that) const {
-			return scopes == that.scopes && level == that.level && it == that.it;
-		}
-		bool operator!= (const const_iterator & that) const { return !( *this == that ); }
-
-		size_type get_level() const { return level; }
-
-		const Note & get_note() const { return (*scopes)[level].note; }
-
-	private:
-		scope_list const *scopes;
-		wrapped_const_iterator it;
-		size_type level;
-	};
+	// Both iterator types are complete bidrectional iterators, see below.
+	class iterator;
+	class const_iterator;
 
 	/// Starts a new scope
@@ -297,11 +147,4 @@
 	}
 
-	template< typename value_type_t >
-	std::pair< iterator, bool > insert( iterator at, value_type_t && value ) {
-		MapType & scope = (*at.scopes)[ at.level ].map;
-		std::pair< typename MapType::iterator, bool > res = scope.insert( std::forward<value_type_t>( value ) );
-		return std::make_pair( iterator(scopes, std::move( res.first ), at.level), std::move( res.second ) );
-	}
-
 	template< typename value_t >
 	std::pair< iterator, bool > insert( const Key & key, value_t && value ) { return insert( std::make_pair( key, std::forward<value_t>( value ) ) ); }
@@ -324,9 +167,10 @@
 	}
 
-	iterator erase( iterator pos ) {
-		MapType & scope = (*pos.scopes)[ pos.level ].map;
-		const typename iterator::wrapped_iterator & new_it = scope.erase( pos.it );
-		iterator it( *pos.scopes, new_it, pos.level );
-		return it.next_valid();
+	/// Erases element with key in the innermost scope that has it.
+	size_type erase( const Key & key ) {
+		for ( auto it = scopes.rbegin() ; it != scopes.rend() ; ++it ) {
+			if ( size_type i = it->map.erase( key ) ; 0 != i ) return i;
+		}
+		return 0;
 	}
 
@@ -343,4 +187,166 @@
 		return c;
 	}
+
+	bool contains( const Key & key ) const {
+		return find( key ) != cend();
+	}
+};
+
+template<typename Key, typename Value, typename Note>
+class ScopedMap<Key, Value, Note>::iterator :
+		public std::iterator< std::bidirectional_iterator_tag, value_type > {
+	friend class ScopedMap;
+	friend class const_iterator;
+	typedef typename ScopedMap::MapType::iterator wrapped_iterator;
+	typedef typename ScopedMap::ScopeList scope_list;
+	typedef typename scope_list::size_type size_type;
+
+	/// Checks if this iterator points to a valid item
+	bool is_valid() const {
+		return it != (*scopes)[level].map.end();
+	}
+
+	/// Increments on invalid
+	iterator & next_valid() {
+		if ( ! is_valid() ) { ++(*this); }
+		return *this;
+	}
+
+	/// Decrements on invalid
+	iterator & prev_valid() {
+		if ( ! is_valid() ) { --(*this); }
+		return *this;
+	}
+
+	iterator(scope_list & _scopes, const wrapped_iterator & _it, size_type inLevel)
+		: scopes(&_scopes), it(_it), level(inLevel) {}
+public:
+	iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
+	iterator & operator= (const iterator & that) {
+		scopes = that.scopes; level = that.level; it = that.it;
+		return *this;
+	}
+
+	reference operator* () { return *it; }
+	pointer operator-> () const { return it.operator->(); }
+
+	iterator & operator++ () {
+		if ( it == (*scopes)[level].map.end() ) {
+			if ( level == 0 ) return *this;
+			--level;
+			it = (*scopes)[level].map.begin();
+		} else {
+			++it;
+		}
+		return next_valid();
+	}
+	iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; }
+
+	iterator & operator-- () {
+		// may fail if this is the begin iterator; allowed by STL spec
+		if ( it == (*scopes)[level].map.begin() ) {
+			++level;
+			it = (*scopes)[level].map.end();
+		}
+		--it;
+		return prev_valid();
+	}
+	iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; }
+
+	bool operator== (const iterator & that) const {
+		return scopes == that.scopes && level == that.level && it == that.it;
+	}
+	bool operator!= (const iterator & that) const { return !( *this == that ); }
+
+	size_type get_level() const { return level; }
+
+	Note & get_note() { return (*scopes)[level].note; }
+	const Note & get_note() const { return (*scopes)[level].note; }
+
+private:
+	scope_list *scopes;
+	wrapped_iterator it;
+	size_type level;
+};
+
+template<typename Key, typename Value, typename Note>
+class ScopedMap<Key, Value, Note>::const_iterator :
+		public std::iterator< std::bidirectional_iterator_tag, value_type > {
+	friend class ScopedMap;
+	typedef typename ScopedMap::MapType::iterator wrapped_iterator;
+	typedef typename ScopedMap::MapType::const_iterator wrapped_const_iterator;
+	typedef typename ScopedMap::ScopeList scope_list;
+	typedef typename scope_list::size_type size_type;
+
+	/// Checks if this iterator points to a valid item
+	bool is_valid() const {
+		return it != (*scopes)[level].map.end();
+	}
+
+	/// Increments on invalid
+	const_iterator & next_valid() {
+		if ( ! is_valid() ) { ++(*this); }
+		return *this;
+	}
+
+	/// Decrements on invalid
+	const_iterator & prev_valid() {
+		if ( ! is_valid() ) { --(*this); }
+		return *this;
+	}
+
+	const_iterator(scope_list const & _scopes, const wrapped_const_iterator & _it, size_type inLevel)
+		: scopes(&_scopes), it(_it), level(inLevel) {}
+public:
+	const_iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
+	const_iterator(const const_iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}
+	const_iterator & operator= (const iterator & that) {
+		scopes = that.scopes; level = that.level; it = that.it;
+		return *this;
+	}
+	const_iterator & operator= (const const_iterator & that) {
+		scopes = that.scopes; level = that.level; it = that.it;
+		return *this;
+	}
+
+	const_reference operator* () { return *it; }
+	const_pointer operator-> () { return it.operator->(); }
+
+	const_iterator & operator++ () {
+		if ( it == (*scopes)[level].map.end() ) {
+			if ( level == 0 ) return *this;
+			--level;
+			it = (*scopes)[level].map.begin();
+		} else {
+			++it;
+		}
+		return next_valid();
+	}
+	const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; }
+
+	const_iterator & operator-- () {
+		// may fail if this is the begin iterator; allowed by STL spec
+		if ( it == (*scopes)[level].map.begin() ) {
+			++level;
+			it = (*scopes)[level].map.end();
+		}
+		--it;
+		return prev_valid();
+	}
+	const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; }
+
+	bool operator== (const const_iterator & that) const {
+		return scopes == that.scopes && level == that.level && it == that.it;
+	}
+	bool operator!= (const const_iterator & that) const { return !( *this == that ); }
+
+	size_type get_level() const { return level; }
+
+	const Note & get_note() const { return (*scopes)[level].note; }
+
+private:
+	scope_list const *scopes;
+	wrapped_const_iterator it;
+	size_type level;
 };
 
Index: src/Common/SemanticError.h
===================================================================
--- src/Common/SemanticError.h	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/Common/SemanticError.h	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May  4 14:08:26 2022
-// Update Count     : 35
+// Last Modified On : Thu Feb  2 10:59:10 2023
+// Update Count     : 36
 //
 
@@ -54,12 +54,13 @@
 
 constexpr WarningData WarningFormats[] = {
-	{"self-assign"            , Severity::Warn    , "self assignment of expression: %s"                          },
-	{"reference-conversion"   , Severity::Warn    , "rvalue to reference conversion of rvalue: %s"               },
-	{"qualifiers-zero_t-one_t", Severity::Warn    , "questionable use of type qualifier %s with %s"              },
-	{"aggregate-forward-decl" , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
-	{"superfluous-decl"       , Severity::Warn    , "declaration does not allocate storage: %s"                  },
-	{"superfluous-else"       , Severity::Warn    , "else clause never executed for empty loop conditional"      },
-	{"gcc-attributes"         , Severity::Warn    , "invalid attribute: %s"                                      },
-	{"c++-like-copy"          , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
+	{"self-assign"              , Severity::Warn    , "self assignment of expression: %s"                          },
+	{"reference-conversion"     , Severity::Warn    , "rvalue to reference conversion of rvalue: %s"               },
+	{"qualifiers-zero_t-one_t"  , Severity::Warn    , "questionable use of type qualifier %s with %s"              },
+	{"aggregate-forward-decl"   , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
+	{"superfluous-decl"         , Severity::Warn    , "declaration does not allocate storage: %s"                  },
+	{"superfluous-else"         , Severity::Warn    , "else clause never executed for empty loop conditional"      },
+	{"gcc-attributes"           , Severity::Warn    , "invalid attribute: %s"                                      },
+	{"c++-like-copy"            , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
+	{"depreciated-trait-syntax" , Severity::Warn    , "trait type-parameters are now specified using the forall clause" },
 };
 
@@ -73,4 +74,5 @@
 	GccAttributes,
 	CppCopy,
+	DeprecTraitSyntax,
 	NUMBER_OF_WARNINGS, // This MUST be the last warning
 };
Index: src/Concurrency/Actors.cpp
===================================================================
--- src/Concurrency/Actors.cpp	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/Concurrency/Actors.cpp	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -21,11 +21,13 @@
 #include "AST/TranslationUnit.hpp"
 #include "AST/Expr.hpp"
+#include <algorithm>
 using namespace ast;
+using namespace std;
 
 namespace Concurrency {
 
 struct CollectactorStructDecls : public ast::WithGuards {
-    std::map<const StructDecl *, int> & actorStructDecls;
-    std::map<const StructDecl *, int>  & messageStructDecls;
+    unordered_set<const StructDecl *> & actorStructDecls;
+    unordered_set<const StructDecl *>  & messageStructDecls;
     const StructDecl ** requestDecl;
     const EnumDecl ** allocationDecl;
@@ -34,9 +36,12 @@
     StructDecl * parentDecl;
     bool insideStruct = false;
-
+    bool namedDecl = false;
+
+    // finds and sets a ptr to the Allocation enum, which is needed in the next pass
     void previsit( const EnumDecl * decl ) {
         if( decl->name == "Allocation" ) *allocationDecl = decl;
     }
 
+    // finds and sets a ptr to the actor, message, and request structs, which are needed in the next pass
     void previsit( const StructDecl * decl ) {
         GuardValue(insideStruct);
@@ -45,14 +50,26 @@
         if( decl->name == "actor" ) *actorDecl = decl;
         if( decl->name == "message" ) *msgDecl = decl;
-        if( decl->name == "request" ) *requestDecl = decl;        
+        if( decl->name == "request" ) *requestDecl = decl;
 	}
 
+    // this catches structs of the form:
+    //     struct dummy_actor { actor a; };
+    // since they should be:
+    //     struct dummy_actor { inline actor; };
+    void previsit ( const ObjectDecl * decl ) {
+        if ( insideStruct && ! decl->name.empty() ) {
+            GuardValue(namedDecl);
+            namedDecl = true;
+        }
+    }
+
+    // this collects the valid actor and message struct decl pts
     void postvisit( const StructInstType * node ) {
         if ( ! *actorDecl || ! *msgDecl ) return;
-        if ( insideStruct ) {
+        if ( insideStruct && !namedDecl ) {
             if ( node->aggr() == *actorDecl ) {
-                actorStructDecls.insert({parentDecl, 1});
+                actorStructDecls.insert( parentDecl );
             } else if ( node->aggr() == *msgDecl ) {
-                messageStructDecls.insert({parentDecl, 1});
+                messageStructDecls.insert( parentDecl );
             }
         }
@@ -60,5 +77,5 @@
 
   public:
-    CollectactorStructDecls( std::map<const StructDecl *, int> & actorStructDecls, std::map<const StructDecl *, int> & messageStructDecls,
+    CollectactorStructDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
         const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl ) 
         : actorStructDecls( actorStructDecls ), messageStructDecls( messageStructDecls ), requestDecl( requestDecl ), 
@@ -66,12 +83,111 @@
 };
 
+// keeps track of all fwdDecls of message routines so that we can hoist them to right after the appropriate decls
+class FwdDeclTable {
+
+    // tracks which decls we have seen so that we can hoist the FunctionDecl to the highest point possible
+    struct FwdDeclData { 
+        const StructDecl * actorDecl;
+        const StructDecl * msgDecl;
+        FunctionDecl * fwdDecl;
+        bool actorFound;
+        bool msgFound;
+
+        bool readyToInsert() { return actorFound && msgFound; }
+        bool foundActor() { actorFound = true; return readyToInsert(); }
+        bool foundMsg() { msgFound = true; return readyToInsert(); }
+
+        FwdDeclData( const StructDecl * actorDecl, const StructDecl * msgDecl, FunctionDecl * fwdDecl ) :
+            actorDecl(actorDecl), msgDecl(msgDecl), fwdDecl(fwdDecl), actorFound(false), msgFound(false) {}
+    };
+
+    // map indexed by actor struct ptr
+    // value is map of all FwdDeclData that contains said actor struct ptr
+    // inner map is indexed by the message struct ptr of FwdDeclData
+    unordered_map<const StructDecl *, unordered_map<const StructDecl *, FwdDeclData *>> actorMap;
+
+    // this map is the same except the outer map is indexed by message ptr and the inner is indexed by actor ptr
+    unordered_map<const StructDecl *, unordered_map<const StructDecl *, FwdDeclData *>> msgMap;
+
+    void insert( const StructDecl * decl, const StructDecl * otherDecl, unordered_map<const StructDecl *, unordered_map<const StructDecl *, FwdDeclData *>> & map, FwdDeclData * data ) {
+        auto iter = map.find( decl );
+        if ( iter != map.end() ) { // if decl exists in map append data to existing inner map
+            iter->second.emplace( make_pair( otherDecl, data ) );
+        } else { // else create inner map for key
+            map.emplace( make_pair( decl, unordered_map<const StructDecl *, FwdDeclData *>( { make_pair( otherDecl, data ) } ) ) );
+        }
+    }
+
+  public:
+    // insert decl into table so that we can fwd declare it later (average cost: O(1))
+    void insertDecl( const StructDecl * actorDecl, const StructDecl * msgDecl, FunctionDecl * fwdDecl ) {
+        FwdDeclData * declToInsert = new FwdDeclData( actorDecl, msgDecl, fwdDecl );
+        insert( actorDecl, msgDecl, actorMap, declToInsert );
+        insert( msgDecl, actorDecl, msgMap, declToInsert );
+    }
+
+    // returns list of decls to insert after current struct decl
+    // Over the entire pass the runtime of this routine is O(r) where r is the # of receive routines
+    list<FunctionDecl *> updateDecl( const StructDecl * decl, bool isMsg ) {
+        unordered_map<const StructDecl *, unordered_map<const StructDecl *, FwdDeclData *>> & map = isMsg ? msgMap : actorMap;
+        unordered_map<const StructDecl *, unordered_map<const StructDecl *, FwdDeclData *>> & otherMap =  isMsg ? actorMap : msgMap;
+        auto iter = map.find( decl );
+        list<FunctionDecl *> toInsertAfter; // this is populated with decls that are ready to insert
+        if ( iter == map.end() ) return toInsertAfter;
+        
+        // iterate over inner map
+        unordered_map<const StructDecl *, FwdDeclData *> & currInnerMap = iter->second;
+        for ( auto innerIter = currInnerMap.begin(); innerIter != currInnerMap.end(); ) {
+            FwdDeclData * currentDatum = innerIter->second;
+            bool readyToInsert = isMsg ? currentDatum->foundMsg() : currentDatum->foundActor();
+            if ( ! readyToInsert ) { ++innerIter; continue; }
+            
+            // readyToInsert is true so we are good to insert the forward decl of the message fn
+            toInsertAfter.push_back( currentDatum->fwdDecl );
+
+            // need to remove from other map before deleting
+            // find inner map in other map ( other map is actor map if original is msg map and vice versa )
+            const StructDecl * otherDecl = isMsg ? currentDatum->actorDecl : currentDatum->msgDecl;
+            auto otherMapIter = otherMap.find( otherDecl );
+
+            unordered_map<const StructDecl *, FwdDeclData *> & otherInnerMap = otherMapIter->second;
+
+            // find the FwdDeclData we need to remove in the other inner map
+            auto otherInnerIter = otherInnerMap.find( decl );
+
+            // remove references to deleted FwdDeclData from current inner map
+            innerIter = currInnerMap.erase( innerIter ); // this does the increment so no explicit inc needed
+
+            // remove references to deleted FwdDeclData from other inner map
+            otherInnerMap.erase( otherInnerIter );
+            
+            // if other inner map is now empty, remove key from other outer map
+            if ( otherInnerMap.empty() )
+                otherMap.erase( otherDecl );
+
+            // now we are safe to delete the FwdDeclData since we are done with it
+            // and we have removed all references to it from our data structures
+            delete currentDatum;
+        }
+
+        // if current inner map is now empty, remove key from outer map.
+        // Have to do this after iterating for safety
+        if ( currInnerMap.empty() )
+            map.erase( decl );
+
+        return toInsertAfter;
+    }
+};
+
+#define __ALLOC 0 // C_TODO: complete swap to no-alloc version
+
 struct GenReceiveDecls : public ast::WithDeclsToAdd<> {
-    std::map<const StructDecl *, int> & actorStructDecls;
-    std::map<const StructDecl *, int>  & messageStructDecls;
+    unordered_set<const StructDecl *> & actorStructDecls;
+    unordered_set<const StructDecl *>  & messageStructDecls;
     const StructDecl ** requestDecl;
     const EnumDecl ** allocationDecl;
     const StructDecl ** actorDecl;
     const StructDecl ** msgDecl;
-    std::vector<FunctionDecl *> & forwardDecls;
+    FwdDeclTable & forwardDecls;
 
 	void postvisit( const FunctionDecl * decl ) {
@@ -90,5 +206,7 @@
 
         // If the struct instances are derived actor and message types then generate the message send routine
-        if ( actorStructDecls.count( arg1InstType->aggr() ) && messageStructDecls.count( arg2InstType->aggr() ) ) {
+        auto actorIter = actorStructDecls.find( arg1InstType->aggr() );
+        auto messageIter = messageStructDecls.find( arg2InstType->aggr() );
+        if ( actorIter != actorStructDecls.end() && messageIter != messageStructDecls.end() ) {
 
             // check that we have found all the decls we need from <actor.hfa>
@@ -107,7 +225,8 @@
                     return receiver;
                 }
-            */
+            */ // C_TODO: update this with new no alloc version
             CompoundStmt * sendBody = new CompoundStmt( decl->location );
 
+            #if __ALLOC
             // Generates: request * new_req = alloc();
             sendBody->push_back( new DeclStmt(
@@ -120,4 +239,15 @@
                 )
             ));
+            #else
+            // Generates: request new_req;
+            sendBody->push_back( new DeclStmt(
+                decl->location,
+                new ObjectDecl(
+                    decl->location,
+                    "new_req",
+                    new StructInstType( *requestDecl )
+                )
+            ));
+            #endif
             
             // Function type is: Allocation (*)( derived_actor &, derived_msg & )
@@ -160,4 +290,5 @@
             ));
 
+            #if __ALLOC
             // Generates: (*new_req){ &receiver, &msg, fn };
             sendBody->push_back( new ExprStmt(
@@ -189,4 +320,35 @@
 				)
 			));
+            #else
+            // Generates: new_req{ &receiver, &msg, fn };
+            sendBody->push_back( new ExprStmt(
+                decl->location,
+				new UntypedExpr (
+                    decl->location, 
+					new NameExpr( decl->location, "?{}" ),
+					{
+						new NameExpr( decl->location, "new_req" ),
+                        new AddressExpr( new NameExpr( decl->location, "receiver" ) ),
+                        new AddressExpr( new NameExpr( decl->location, "msg" ) ),
+                        new NameExpr( decl->location, "fn" )
+					}
+				)
+			));
+
+            // Generates: send( receiver, new_req );
+            sendBody->push_back( new ExprStmt(
+                decl->location,
+				new UntypedExpr (
+                    decl->location,
+					new NameExpr( decl->location, "send" ),
+					{
+						{
+                            new NameExpr( decl->location, "receiver" ),
+                            new NameExpr( decl->location, "new_req" )
+                        }
+					}
+				)
+			));
+            #endif
             
             // Generates: return receiver;
@@ -225,5 +387,6 @@
             
             // forward decls to resolve use before decl problem for '|' routines
-            forwardDecls.push_back( ast::deepCopy( sendOperatorFunction ) );
+            forwardDecls.insertDecl( *actorIter, *messageIter , ast::deepCopy( sendOperatorFunction ) );
+            // forwardDecls.push_back( ast::deepCopy( sendOperatorFunction ) );
 
             sendOperatorFunction->stmts = sendBody;
@@ -233,51 +396,51 @@
 
   public:
-    GenReceiveDecls( std::map<const StructDecl *, int> & actorStructDecls, std::map<const StructDecl *, int> & messageStructDecls,
+    GenReceiveDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
         const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl, 
-        std::vector<FunctionDecl *> & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 
+        FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 
         requestDecl(requestDecl), allocationDecl(allocationDecl), actorDecl(actorDecl), msgDecl(msgDecl), forwardDecls(forwardDecls) {}
 };
 
 struct GenFwdDecls : public ast::WithDeclsToAdd<> {
-    std::map<const StructDecl *, int> & actorStructDecls;
-    std::map<const StructDecl *, int>  & messageStructDecls;
-    std::vector<FunctionDecl *> & forwardDecls;
-    bool done;
-
-    void postvisit( const FunctionDecl * decl ) {
-        if ( done ) return;
-        // return if not of the form receive( param1, param2 ) or if it is a forward decl
-        if ( decl->name != "receive" || decl->params.size() != 2 || !decl->stmts ) return;
-
-        // the params should be references
-        const ReferenceType * derivedActorRef = dynamic_cast<const ReferenceType *>(decl->params.at(0)->get_type());
-        const ReferenceType * derivedMsgRef = dynamic_cast<const ReferenceType *>(decl->params.at(1)->get_type());
-        if ( !derivedActorRef || !derivedMsgRef ) return;
-
-        // the references should be to struct instances
-        const StructInstType * arg1InstType = dynamic_cast<const StructInstType *>(derivedActorRef->base.get());
-        const StructInstType * arg2InstType = dynamic_cast<const StructInstType *>(derivedMsgRef->base.get());
-        if ( !arg1InstType || !arg2InstType ) return;
-
-        // If the struct instances are derived actor and message types then generate the message send routine
-        if ( actorStructDecls.count( arg1InstType->aggr() ) && messageStructDecls.count( arg2InstType->aggr() ) ) {
-            done = true;
-            for ( const auto & func : forwardDecls ) {
-                declsToAddBefore.push_back( func );
-            }
+    unordered_set<const StructDecl *> & actorStructDecls;
+    unordered_set<const StructDecl *>  & messageStructDecls;
+    FwdDeclTable & forwardDecls;
+
+    void postvisit( const StructDecl * decl ) {
+        list<FunctionDecl *> toAddAfter;
+        auto actorIter = actorStructDecls.find( decl );
+        if ( actorIter != actorStructDecls.end() ) { // this is a derived actor decl
+            // get list of fwd decls that we can now insert
+            toAddAfter = forwardDecls.updateDecl( decl, false );
+
+            // get rid of decl from actorStructDecls since we no longer need it
+            actorStructDecls.erase( actorIter );
+        } else {
+            auto messageIter = messageStructDecls.find( decl );
+            if ( messageIter == messageStructDecls.end() ) return;
+
+            toAddAfter = forwardDecls.updateDecl( decl, true );
+
+            // get rid of decl from messageStructDecls since we no longer need it
+            messageStructDecls.erase( messageIter );
+        }
+
+        // add the fwd decls to declsToAddAfter
+        for ( FunctionDecl * func : toAddAfter ) {
+            declsToAddAfter.push_back( func );
         }
     }
 
   public:
-    GenFwdDecls( std::map<const StructDecl *, int> & actorStructDecls, std::map<const StructDecl *, int> & messageStructDecls, 
-        std::vector<FunctionDecl *> & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls),
-        forwardDecls(forwardDecls), done(false) {}
+    GenFwdDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 
+        FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls),
+        forwardDecls(forwardDecls) {}
 };
 
 void implementActors( TranslationUnit & translationUnit ) {
-    // maps to collect all derived actor and message types
-    std::map<const StructDecl *, int> actorStructDecls;
-    std::map<const StructDecl *, int> messageStructDecls;
-    std::vector<FunctionDecl *> forwardDecls;
+    // unordered_maps to collect all derived actor and message types
+    unordered_set<const StructDecl *> actorStructDecls;
+    unordered_set<const StructDecl *> messageStructDecls;
+    FwdDeclTable forwardDecls;
 
     // for storing through the passes
Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/GenPoly/Box.cc	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -488,5 +488,5 @@
 				for ( FunctionType const * const funType : functions ) {
 					std::string mangleName = mangleAdapterName( funType, scopeTyVars );
-					if ( adapters.find( mangleName ) == adapters.end() ) {
+					if ( !adapters.contains( mangleName ) ) {
 						std::string adapterName = makeAdapterName( mangleName );
 						adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( funType, scopeTyVars ) ), nullptr ) ) );
@@ -1487,5 +1487,5 @@
 					if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) {
 						// do not try to monomorphize generic parameters
-						if ( scopeTyVars.find( typeInst->get_name() ) != scopeTyVars.end() && ! genericParams.count( typeInst->name ) ) {
+						if ( scopeTyVars.contains( typeInst->get_name() ) && ! genericParams.count( typeInst->name ) ) {
 							// polymorphic aggregate members should be converted into monomorphic members.
 							// Using char[size_T] here respects the expected sizing rules of an aggregate type.
@@ -1696,5 +1696,5 @@
 
 			if ( auto typeInst = dynamic_cast< TypeInstType const * >( ty ) ) {
-				if ( scopeTyVars.find( typeInst->get_name() ) != scopeTyVars.end() ) {
+				if ( scopeTyVars.contains( typeInst->get_name() ) ) {
 					// NOTE assumes here that getting put in the scopeTyVars included having the layout variables set
 					return true;
@@ -1704,5 +1704,5 @@
 				// check if this type already has a layout generated for it
 				std::string typeName = mangleType( ty );
-				if ( knownLayouts.find( typeName ) != knownLayouts.end() ) return true;
+				if ( knownLayouts.contains( typeName ) ) return true;
 
 				// check if any of the type parameters have dynamic layout; if none do, this type is (or will be) monomorphized
@@ -1741,5 +1741,5 @@
 				// check if this type already has a layout generated for it
 				std::string typeName = mangleType( ty );
-				if ( knownLayouts.find( typeName ) != knownLayouts.end() ) return true;
+				if ( knownLayouts.contains( typeName ) ) return true;
 
 				// check if any of the type parameters have dynamic layout; if none do, this type is (or will be) monomorphized
@@ -1832,5 +1832,5 @@
 			} else {
 				std::string offsetName = offsetofName( mangleType( ty ) );
-				if ( knownOffsets.find( offsetName ) != knownOffsets.end() ) {
+				if ( knownOffsets.contains( offsetName ) ) {
 					// use the already-generated offsets for this type
 					ret = new NameExpr( offsetName );
Index: src/GenPoly/ErasableScopedMap.h
===================================================================
--- src/GenPoly/ErasableScopedMap.h	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/GenPoly/ErasableScopedMap.h	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// ScopedMap.h --
+// ErasableScopedMap.h --
 //
 // Author           : Aaron B. Moss
@@ -51,5 +51,5 @@
 	typedef typename Scope::const_pointer const_pointer;
 
-	// Both iterator types are complete bidirection iterators, defined below.
+	// Both iterator types are complete bidirectional iterators, see below.
 	class iterator;
 	class const_iterator;
@@ -118,4 +118,10 @@
 	std::pair< iterator, bool > insert( const Key &key, const Value &value ) { return insert( std::make_pair( key, value ) ); }
 
+	Value& operator[] ( const Key &key ) {
+		iterator slot = find( key );
+		if ( slot != end() ) return slot->second;
+		return insert( key, Value() ).first->second;
+	}
+
 	/// Marks the given element as erased from this scope inward; returns 1 for erased an element, 0 otherwise
 	size_type erase( const Key &key ) {
@@ -130,8 +136,6 @@
 	}
 
-	Value& operator[] ( const Key &key ) {
-		iterator slot = find( key );
-		if ( slot != end() ) return slot->second;
-		return insert( key, Value() ).first->second;
+	bool contains( const Key & key ) const {
+		return find( key ) != cend();
 	}
 };
Index: src/GenPoly/GenPoly.cc
===================================================================
--- src/GenPoly/GenPoly.cc	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/GenPoly/GenPoly.cc	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -172,5 +172,5 @@
 
 		if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
-			if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
+			if ( tyVars.contains( typeInst->get_name() ) ) {
 				return type;
 			}
@@ -189,5 +189,5 @@
 
 		if ( auto typeInst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
-			return tyVars.find(typeInst->typeString()) != tyVars.end() ? type : nullptr;
+			if ( tyVars.contains( typeInst->typeString() ) ) return type;
 		} else if ( auto arrayType = dynamic_cast< const ast::ArrayType * >( type ) ) {
 			return isPolyType( arrayType->base, env );
@@ -205,5 +205,5 @@
 
 	if ( auto inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
-		if ( typeVars.find( *inst ) != typeVars.end() ) return type;
+		if ( typeVars.contains( *inst ) ) return type;
 	} else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) {
 		return isPolyType( array->base, subst );
@@ -393,5 +393,5 @@
 
 		if ( TypeInstType *typeInstType = dynamic_cast< TypeInstType * >( type ) ) {
-			if ( tyVars.find( typeInstType->get_name() ) != tyVars.end() ) {
+			if ( tyVars.contains( typeInstType->get_name() ) ) {
 				return true;
 			}
Index: src/GenPoly/ScopedSet.h
===================================================================
--- src/GenPoly/ScopedSet.h	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/GenPoly/ScopedSet.h	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -21,231 +21,243 @@
 
 namespace GenPoly {
-	/// A set where the items are placed into nested scopes;
-	/// inserted items are placed into the innermost scope, lookup looks from the innermost scope outward
-	template<typename Value>
-	class ScopedSet {
-		typedef std::set< Value > Scope;
-		typedef std::vector< Scope > ScopeList;
-
-		ScopeList scopes; ///< scoped list of sets
-	public:
-		typedef typename Scope::key_type key_type;
-		typedef typename Scope::value_type value_type;
-		typedef typename ScopeList::size_type size_type;
-		typedef typename ScopeList::difference_type difference_type;
-		typedef typename Scope::reference reference;
-		typedef typename Scope::const_reference const_reference;
-		typedef typename Scope::pointer pointer;
-		typedef typename Scope::const_pointer const_pointer;
-
-		class iterator : public std::iterator< std::bidirectional_iterator_tag,
-		                                       value_type > {
-		friend class ScopedSet;
-		friend class const_iterator;
-			typedef typename std::set< Value >::iterator wrapped_iterator;
-			typedef typename std::vector< std::set< Value > > scope_list;
-			typedef typename scope_list::size_type size_type;
-
-			/// Checks if this iterator points to a valid item
-			bool is_valid() const {
-				return it != (*scopes)[i].end();
-			}
-
-			/// Increments on invalid
-			iterator& next_valid() {
-				if ( ! is_valid() ) { ++(*this); }
-				return *this;
-			}
-
-			/// Decrements on invalid
-			iterator& prev_valid() {
-				if ( ! is_valid() ) { --(*this); }
-				return *this;
-			}
-
-			iterator(scope_list const &_scopes, const wrapped_iterator &_it, size_type _i)
-				: scopes(&_scopes), it(_it), i(_i) {}
-		public:
-			iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
-			iterator& operator= (const iterator &that) {
-				scopes = that.scopes; i = that.i; it = that.it;
-				return *this;
-			}
-
-			reference operator* () { return *it; }
-			pointer operator-> () { return it.operator->(); }
-
-			iterator& operator++ () {
-				if ( it == (*scopes)[i].end() ) {
-					if ( i == 0 ) return *this;
-					--i;
-					it = (*scopes)[i].begin();
-				} else {
-					++it;
-				}
-				return next_valid();
-			}
-			iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; }
-
-			iterator& operator-- () {
-				// may fail if this is the begin iterator; allowed by STL spec
-				if ( it == (*scopes)[i].begin() ) {
-					++i;
-					it = (*scopes)[i].end();
-				}
-				--it;
-				return prev_valid();
-			}
-			iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; }
-
-			bool operator== (const iterator &that) {
-				return scopes == that.scopes && i == that.i && it == that.it;
-			}
-			bool operator!= (const iterator &that) { return !( *this == that ); }
-
-			size_type get_level() const { return i; }
-
-		private:
-			scope_list const *scopes;
-			wrapped_iterator it;
-			size_type i;
-		};
-
-		class const_iterator : public std::iterator< std::bidirectional_iterator_tag,
-		                                             value_type > {
-		friend class ScopedSet;
-			typedef typename std::set< Value >::iterator wrapped_iterator;
-			typedef typename std::set< Value >::const_iterator wrapped_const_iterator;
-			typedef typename std::vector< std::set< Value > > scope_list;
-			typedef typename scope_list::size_type size_type;
-
-			/// Checks if this iterator points to a valid item
-			bool is_valid() const {
-				return it != (*scopes)[i].end();
-			}
-
-			/// Increments on invalid
-			const_iterator& next_valid() {
-				if ( ! is_valid() ) { ++(*this); }
-				return *this;
-			}
-
-			/// Decrements on invalid
-			const_iterator& prev_valid() {
-				if ( ! is_valid() ) { --(*this); }
-				return *this;
-			}
-
-			const_iterator(scope_list const &_scopes, const wrapped_const_iterator &_it, size_type _i)
-				: scopes(&_scopes), it(_it), i(_i) {}
-		public:
-			const_iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
-			const_iterator(const const_iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
-			const_iterator& operator= (const iterator &that) {
-				scopes = that.scopes; i = that.i; it = that.it;
-				return *this;
-			}
-			const_iterator& operator= (const const_iterator &that) {
-				scopes = that.scopes; i = that.i; it = that.it;
-				return *this;
-			}
-
-			const_reference operator* () { return *it; }
-			const_pointer operator-> () { return it.operator->(); }
-
-			const_iterator& operator++ () {
-				if ( it == (*scopes)[i].end() ) {
-					if ( i == 0 ) return *this;
-					--i;
-					it = (*scopes)[i].begin();
-				} else {
-					++it;
-				}
-				return next_valid();
-			}
-			const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; }
-
-			const_iterator& operator-- () {
-				// may fail if this is the begin iterator; allowed by STL spec
-				if ( it == (*scopes)[i].begin() ) {
-					++i;
-					it = (*scopes)[i].end();
-				}
-				--it;
-				return prev_valid();
-			}
-			const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; }
-
-			bool operator== (const const_iterator &that) {
-				return scopes == that.scopes && i == that.i && it == that.it;
-			}
-			bool operator!= (const const_iterator &that) { return !( *this == that ); }
-
-			size_type get_level() const { return i; }
-
-		private:
-			scope_list const *scopes;
-			wrapped_const_iterator it;
-			size_type i;
-		};
-
-		/// Starts a new scope
-		void beginScope() {
-			Scope scope;
-			scopes.push_back(scope);
-		}
-
-		/// Ends a scope; invalidates any iterators pointing to elements of that scope
-		void endScope() {
-			scopes.pop_back();
-		}
-
-		/// Default constructor initializes with one scope
-		ScopedSet() { beginScope(); }
-
-		iterator begin() { return iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
-		const_iterator begin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
-		const_iterator cbegin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
-		iterator end() { return iterator(scopes, scopes[0].end(), 0); }
-		const_iterator end() const { return const_iterator(scopes, scopes[0].end(), 0); }
-		const_iterator cend() const { return const_iterator(scopes, scopes[0].end(), 0); }
-
-		/// Gets the index of the current scope (counted from 1)
-		size_type currentScope() const { return scopes.size(); }
-
-		/// Finds the given key in the outermost scope it occurs; returns end() for none such
-		iterator find( const Value &key ) {
-			for ( size_type i = scopes.size() - 1; ; --i ) {
-				typename Scope::iterator val = scopes[i].find( key );
-				if ( val != scopes[i].end() ) return iterator( scopes, val, i );
-				if ( i == 0 ) break;
-			}
-			return end();
-		}
-		const_iterator find( const Value &key ) const {
-			return const_iterator( const_cast< ScopedSet< Value >* >(this)->find( key ) );
-		}
-
-		/// Finds the given key in the outermost scope inside the given scope where it occurs
-		iterator findNext( const_iterator &it, const Value &key ) {
-			if ( it.i == 0 ) return end();
+
+/// A set where the items are placed into nested scopes;
+/// inserted items are placed into the innermost scope, lookup looks from the innermost scope outward
+template<typename Value>
+class ScopedSet {
+	typedef std::set< Value > Scope;
+	typedef std::vector< Scope > ScopeList;
+
+	/// Scoped list of sets.
+	ScopeList scopes;
+public:
+	typedef typename Scope::key_type key_type;
+	typedef typename Scope::value_type value_type;
+	typedef typename ScopeList::size_type size_type;
+	typedef typename ScopeList::difference_type difference_type;
+	typedef typename Scope::reference reference;
+	typedef typename Scope::const_reference const_reference;
+	typedef typename Scope::pointer pointer;
+	typedef typename Scope::const_pointer const_pointer;
+
+	// Both iterator types are complete bidirectional iterators, see below.
+	class iterator;
+	class const_iterator;
+
+	/// Starts a new scope
+	void beginScope() {
+		Scope scope;
+		scopes.push_back(scope);
+	}
+
+	/// Ends a scope; invalidates any iterators pointing to elements of that scope
+	void endScope() {
+		scopes.pop_back();
+	}
+
+	/// Default constructor initializes with one scope
+	ScopedSet() { beginScope(); }
+
+	iterator begin() { return iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
+	const_iterator begin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
+	const_iterator cbegin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); }
+	iterator end() { return iterator(scopes, scopes[0].end(), 0); }
+	const_iterator end() const { return const_iterator(scopes, scopes[0].end(), 0); }
+	const_iterator cend() const { return const_iterator(scopes, scopes[0].end(), 0); }
+
+	/// Gets the index of the current scope (counted from 1)
+	size_type currentScope() const { return scopes.size(); }
+
+	/// Finds the given key in the outermost scope it occurs; returns end() for none such
+	iterator find( const Value &key ) {
+		for ( size_type i = scopes.size() - 1; ; --i ) {
+			typename Scope::iterator val = scopes[i].find( key );
+			if ( val != scopes[i].end() ) return iterator( scopes, val, i );
+			if ( i == 0 ) break;
+		}
+		return end();
+	}
+	const_iterator find( const Value &key ) const {
+		return const_iterator( const_cast< ScopedSet< Value >* >(this)->find( key ) );
+	}
+
+	/// Finds the given key in the outermost scope inside the given scope where it occurs
+	iterator findNext( const_iterator &it, const Value &key ) {
+		if ( it.i == 0 ) return end();
 			for ( size_type i = it.i - 1; ; --i ) {
-				typename Scope::iterator val = scopes[i].find( key );
-				if ( val != scopes[i].end() ) return iterator( scopes, val, i );
-				if ( i == 0 ) break;
-			}
-			return end();
-		}
-		const_iterator findNext( const_iterator &it, const Value &key ) const {
-			return const_iterator( const_cast< ScopedSet< Value >* >(this)->findNext( it, key ) );
-		}
-
-		/// Inserts the given value into the outermost scope
-		std::pair< iterator, bool > insert( const value_type &value ) {
-			std::pair< typename Scope::iterator, bool > res = scopes.back().insert( value );
-			return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second );
-		}
-
-	};
+			typename Scope::iterator val = scopes[i].find( key );
+			if ( val != scopes[i].end() ) return iterator( scopes, val, i );
+			if ( i == 0 ) break;
+		}
+		return end();
+	}
+	const_iterator findNext( const_iterator &it, const Value &key ) const {
+		return const_iterator( const_cast< ScopedSet< Value >* >(this)->findNext( it, key ) );
+	}
+
+	/// Inserts the given value into the outermost scope
+	std::pair< iterator, bool > insert( const value_type &value ) {
+		std::pair< typename Scope::iterator, bool > res = scopes.back().insert( value );
+		return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second );
+	}
+
+	bool contains( const Value & key ) const {
+		return find( key ) != cend();
+	}
+};
+
+template<typename Value>
+class ScopedSet<Value>::iterator :
+		public std::iterator< std::bidirectional_iterator_tag, value_type > {
+	friend class ScopedSet;
+	friend class const_iterator;
+	typedef typename std::set< Value >::iterator wrapped_iterator;
+	typedef typename std::vector< std::set< Value > > scope_list;
+	typedef typename scope_list::size_type size_type;
+
+	/// Checks if this iterator points to a valid item
+	bool is_valid() const {
+		return it != (*scopes)[i].end();
+	}
+
+	/// Increments on invalid
+	iterator& next_valid() {
+		if ( ! is_valid() ) { ++(*this); }
+		return *this;
+	}
+
+	/// Decrements on invalid
+	iterator& prev_valid() {
+		if ( ! is_valid() ) { --(*this); }
+		return *this;
+	}
+
+	iterator(scope_list const &_scopes, const wrapped_iterator &_it, size_type _i)
+		: scopes(&_scopes), it(_it), i(_i) {}
+public:
+	iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
+	iterator& operator= (const iterator &that) {
+		scopes = that.scopes; i = that.i; it = that.it;
+		return *this;
+	}
+
+	reference operator* () { return *it; }
+	pointer operator-> () { return it.operator->(); }
+
+	iterator& operator++ () {
+		if ( it == (*scopes)[i].end() ) {
+			if ( i == 0 ) return *this;
+			--i;
+			it = (*scopes)[i].begin();
+		} else {
+			++it;
+		}
+		return next_valid();
+	}
+	iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; }
+
+	iterator& operator-- () {
+		// may fail if this is the begin iterator; allowed by STL spec
+		if ( it == (*scopes)[i].begin() ) {
+			++i;
+			it = (*scopes)[i].end();
+		}
+		--it;
+		return prev_valid();
+	}
+	iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; }
+
+	bool operator== (const iterator &that) {
+		return scopes == that.scopes && i == that.i && it == that.it;
+	}
+	bool operator!= (const iterator &that) { return !( *this == that ); }
+
+	size_type get_level() const { return i; }
+
+private:
+	scope_list const *scopes;
+	wrapped_iterator it;
+	size_type i;
+};
+
+template<typename Value>
+class ScopedSet<Value>::const_iterator :
+		public std::iterator< std::bidirectional_iterator_tag, value_type > {
+	friend class ScopedSet;
+	typedef typename std::set< Value >::iterator wrapped_iterator;
+	typedef typename std::set< Value >::const_iterator wrapped_const_iterator;
+	typedef typename std::vector< std::set< Value > > scope_list;
+	typedef typename scope_list::size_type size_type;
+
+	/// Checks if this iterator points to a valid item
+	bool is_valid() const {
+		return it != (*scopes)[i].end();
+	}
+
+	/// Increments on invalid
+	const_iterator& next_valid() {
+		if ( ! is_valid() ) { ++(*this); }
+		return *this;
+	}
+
+	/// Decrements on invalid
+	const_iterator& prev_valid() {
+		if ( ! is_valid() ) { --(*this); }
+		return *this;
+	}
+
+	const_iterator(scope_list const &_scopes, const wrapped_const_iterator &_it, size_type _i)
+		: scopes(&_scopes), it(_it), i(_i) {}
+public:
+	const_iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
+	const_iterator(const const_iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {}
+	const_iterator& operator= (const iterator &that) {
+		scopes = that.scopes; i = that.i; it = that.it;
+		return *this;
+	}
+	const_iterator& operator= (const const_iterator &that) {
+		scopes = that.scopes; i = that.i; it = that.it;
+		return *this;
+	}
+
+	const_reference operator* () { return *it; }
+	const_pointer operator-> () { return it.operator->(); }
+
+	const_iterator& operator++ () {
+		if ( it == (*scopes)[i].end() ) {
+			if ( i == 0 ) return *this;
+			--i;
+			it = (*scopes)[i].begin();
+		} else {
+			++it;
+		}
+		return next_valid();
+	}
+	const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; }
+
+	const_iterator& operator-- () {
+		// may fail if this is the begin iterator; allowed by STL spec
+		if ( it == (*scopes)[i].begin() ) {
+			++i;
+			it = (*scopes)[i].end();
+		}
+		--it;
+		return prev_valid();
+	}
+	const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; }
+
+	bool operator== (const const_iterator &that) {
+		return scopes == that.scopes && i == that.i && it == that.it;
+	}
+	bool operator!= (const const_iterator &that) { return !( *this == that ); }
+
+	size_type get_level() const { return i; }
+
+private:
+	scope_list const *scopes;
+	wrapped_const_iterator it;
+	size_type i;
+};
+
 } // namespace GenPoly
 
Index: src/GenPoly/ScrubTyVars.cc
===================================================================
--- src/GenPoly/ScrubTyVars.cc	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/GenPoly/ScrubTyVars.cc	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -178,31 +178,27 @@
 
 ast::Type const * ScrubTypeVars::postvisit( ast::TypeInstType const * type ) {
+	ast::TypeDecl::Kind kind;
 	// This implies that mode == ScrubMode::All.
 	if ( !typeVars ) {
-		if ( ast::TypeDecl::Ftype == type->kind ) {
-			return new ast::PointerType(
-				new ast::FunctionType( ast::FixedArgs ) );
-		} else {
-			return new ast::PointerType(
-				new ast::VoidType( type->qualifiers ) );
-		}
-	}
-
-	auto typeVar = typeVars->find( *type );
-	if ( typeVar == typeVars->end() ) {
-		return type;
-	}
-
-	switch ( typeVar->second.kind ) {
-	case ::TypeDecl::Dtype:
-	case ::TypeDecl::Ttype:
+		kind = type->kind;
+	} else {
+		// Otherwise, only scrub the type var if it is in map.
+		auto typeVar = typeVars->find( *type );
+		if ( typeVar == typeVars->end() ) {
+			return type;
+		}
+		kind = typeVar->second.kind;
+	}
+
+	switch ( kind ) {
+	case ast::TypeDecl::Dtype:
+	case ast::TypeDecl::Ttype:
 		return new ast::PointerType(
 			new ast::VoidType( type->qualifiers ) );
-	case ::TypeDecl::Ftype:
+	case ast::TypeDecl::Ftype:
 		return new ast::PointerType(
 			new ast::FunctionType( ast::VariableArgs ) );
 	default:
-		assertf( false,
-			"Unhandled type variable kind: %d", typeVar->second.kind );
+		assertf( false, "Unhandled type variable kind: %d", kind );
 		throw; // Just in case the assert is removed, stop here.
 	}
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/Parser/parser.yy	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 30 20:47:27 2023
-// Update Count     : 5859
+// Last Modified On : Thu Feb  2 21:36:16 2023
+// Update Count     : 5865
 //
 
@@ -2080,9 +2080,10 @@
 		{ $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
 	| forall
+		{ $$ = DeclarationNode::newForall( $1 ); }
 	;
 
 forall:
 	FORALL '(' type_parameter_list ')'					// CFA
-		{ $$ = DeclarationNode::newForall( $3 ); }
+		{ $$ = $3; }
 	;
 
@@ -2978,11 +2979,17 @@
 trait_specifier:										// CFA
 	TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
-		{ $$ = DeclarationNode::newTrait( $2, $4, nullptr ); }
-	| FORALL '(' type_parameter_list ')' TRAIT identifier_or_type_name '{' '}' // alternate
-		{ $$ = DeclarationNode::newTrait( $6, $3, nullptr ); }
+		{
+			SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
+			$$ = DeclarationNode::newTrait( $2, $4, nullptr );
+		}
+	| forall TRAIT identifier_or_type_name '{' '}'		// alternate
+		{ $$ = DeclarationNode::newTrait( $3, $1, nullptr ); }
 	| TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
-		{ $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
-	| FORALL '(' type_parameter_list ')' TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
-		{ $$ = DeclarationNode::newTrait( $6, $3, $9 ); }
+		{
+			SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
+			$$ = DeclarationNode::newTrait( $2, $4, $8 );
+		}
+	| forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
+		{ $$ = DeclarationNode::newTrait( $3, $1, $6 ); }
 	;
 
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/SymTab/Validate.cc	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -863,9 +863,5 @@
 
 	void ReplaceTypedef::premutate( TypeDecl * typeDecl ) {
-		TypedefMap::iterator i = typedefNames.find( typeDecl->name );
-		if ( i != typedefNames.end() ) {
-			typedefNames.erase( i ) ;
-		} // if
-
+		typedefNames.erase( typeDecl->name );
 		typedeclNames.insert( typeDecl->name, typeDecl );
 	}
Index: src/Validate/ReplaceTypedef.cpp
===================================================================
--- src/Validate/ReplaceTypedef.cpp	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ src/Validate/ReplaceTypedef.cpp	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -186,8 +186,5 @@
 
 void ReplaceTypedefCore::previsit( ast::TypeDecl const * decl ) {
-	TypedefMap::iterator iter = typedefNames.find( decl->name );
-	if ( iter != typedefNames.end() ) {
-		typedefNames.erase( iter );
-	}
+	typedefNames.erase( decl->name );
 	typedeclNames.insert( decl->name, decl );
 }
Index: tests/.expect/forall.txt
===================================================================
--- tests/.expect/forall.txt	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ tests/.expect/forall.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -1,1 +1,21 @@
-forall.cfa:244:25: warning: Compiled
+1
+f
+97
+f
+g
+f
+f
+g
+fT
+fT
+fT
+fTU
+fTU
+fTU
+1 2
+2 1
+1, 2
+@ 0 2 0 4 6.4 6.4 6.4 6.4+3.i 4
+3. 3.
+45
+12 3
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ tests/Makefile.am	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -11,6 +11,6 @@
 ## Created On       : Sun May 31 09:08:15 2015
 ## Last Modified By : Peter A. Buhr
-## Last Modified On : Sat Jun  5 14:49:25 2021
-## Update Count     : 92
+## Last Modified On : Fri Feb  3 23:06:44 2023
+## Update Count     : 94
 ###############################################################################
 
@@ -89,5 +89,5 @@
 	meta/fork+exec.hfa \
 	concurrent/unified_locking/mutex_test.hfa \
-    concurrent/channels/parallel_harness.hfa
+	concurrent/channels/parallel_harness.hfa
 
 dist-hook:
@@ -183,5 +183,5 @@
 CFACOMPILE_SYNTAX = $(CFACOMPILETEST) -Wno-unused-variable -Wno-unused-label -c -fsyntax-only -o $(abspath ${@})
 
-SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator forall \
+SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator \
 	init1 limits nested-types cast labelledExit array quasiKeyword include/stdincludes include/includes builtins/sync warnings/self-assignment
 $(SYNTAX_ONLY_CODE): % : %.cfa $(CFACCBIN)
Index: tests/concurrent/actors/.expect/dynamic.txt
===================================================================
--- tests/concurrent/actors/.expect/dynamic.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/.expect/dynamic.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,5 @@
+starting
+started
+stopping
+Done
+stopped
Index: tests/concurrent/actors/.expect/executor.txt
===================================================================
--- tests/concurrent/actors/.expect/executor.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/.expect/executor.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,4 @@
+starting
+started
+stopping
+stopped
Index: tests/concurrent/actors/.expect/static.txt
===================================================================
--- tests/concurrent/actors/.expect/static.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/.expect/static.txt	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,5 @@
+starting
+started
+stopping
+Done
+stopped
Index: tests/concurrent/actors/dynamic.cfa
===================================================================
--- tests/concurrent/actors/dynamic.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/dynamic.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,74 @@
+#include <actor.hfa>
+#include <fstream.hfa>
+#include <stdlib.hfa>
+#include <string.h>
+#include <stdio.h>
+
+int Times = 1000000;								// default values
+
+struct derived_actor {
+    inline actor;
+};
+void ?{}( derived_actor & this ) { ((actor &)this){}; }
+
+struct derived_msg {
+    inline message;
+    int cnt;
+};
+
+void ?{}( derived_msg & this, int cnt ) {
+    ((message &) this){ Delete };
+    this.cnt = cnt;
+}
+void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
+
+
+Allocation receive( derived_actor & receiver, derived_msg & msg ) {
+    if ( msg.cnt >= Times ) {
+        sout | "Done";
+        return Delete;
+    }
+    derived_msg * d_msg = alloc();
+    (*d_msg){ msg.cnt + 1 };
+    derived_actor * d_actor = alloc();
+    (*d_actor){};
+    *d_actor | *d_msg;
+    return Delete;
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Times = atoi( argv[1] );
+			if ( Times < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0] | " [ times (> 0) ]";
+		exit( EXIT_FAILURE );
+	} // switch
+
+    printf("starting\n");
+
+    executor e{ 0, 1, 1, false };
+    start_actor_system( e );
+
+    printf("started\n");
+
+    derived_msg * d_msg = alloc();
+    (*d_msg){};
+    derived_actor * d_actor = alloc();
+    (*d_actor){};
+    *d_actor | *d_msg;
+
+    printf("stopping\n");
+
+    stop_actor_system();
+
+    printf("stopped\n");
+
+    return 0;
+}
Index: tests/concurrent/actors/executor.cfa
===================================================================
--- tests/concurrent/actors/executor.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/executor.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,109 @@
+#include <actor.hfa>
+#include <fstream.hfa>
+#include <stdlib.hfa>
+#include <string.h>
+#include <stdio.h>
+
+// int Actors = 40000, Set = 100, Rounds = 100, Processors = 1, Batch = 1, BufSize = 10; // default values
+int Actors = 1000, Set = 20, Rounds = 10, Processors = 1, Batch = 1, BufSize = 10; // other defaults for test to run in reasonable time
+
+static int ids = 0;
+struct d_actor { 
+    inline actor;
+    d_actor * gstart;
+    int id, rounds, recs, sends;
+};
+void ?{}( d_actor & this ) with(this) {
+    ((actor &)this){};
+    id = ids++;
+    gstart = (&this + (id / Set * Set - id)); // remember group-start array-element
+    rounds = Set * Rounds;	// send at least one message to each group member
+    recs = 0;
+    sends = 0;
+}
+
+struct d_msg { inline message; } shared_msg;
+void ?{}( d_msg & this ) { ((message &) this){ Nodelete }; }
+
+Allocation receive( d_actor & this, d_msg & msg ) with( this ) {
+    if ( recs == rounds ) return Finished;
+    if ( recs % Batch == 0 ) {
+        for ( i; Batch ) {
+            gstart[sends % Set] | shared_msg;
+            sends += 1;
+        }
+    }
+    recs += 1;
+    return Nodelete;
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 7:
+		if ( strcmp( argv[6], "d" ) != 0 ) {			// default ?
+			BufSize = atoi( argv[6] );
+			if ( BufSize < 0 ) goto Usage;
+		} // if
+	  case 6:
+		if ( strcmp( argv[5], "d" ) != 0 ) {			// default ?
+			Batch = atoi( argv[5] );
+			if ( Batch < 1 ) goto Usage;
+		} // if
+	  case 5:
+		if ( strcmp( argv[4], "d" ) != 0 ) {			// default ?
+			Processors = atoi( argv[4] );
+			if ( Processors < 1 ) goto Usage;
+		} // if
+	  case 4:
+		if ( strcmp( argv[3], "d" ) != 0 ) {			// default ?
+			Rounds = atoi( argv[3] );
+			if ( Rounds < 1 ) goto Usage;
+		} // if
+	  case 3:
+		if ( strcmp( argv[2], "d" ) != 0 ) {			// default ?
+			Set = atoi( argv[2] );
+			if ( Set < 1 ) goto Usage;
+		} // if
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Actors = atoi( argv[1] );
+			if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0]
+             | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors
+			 | ") ] [ set (> 0) | 'd' (default " | Set
+			 | ") ] [ rounds (> 0) | 'd' (default " | Rounds
+			 | ") ] [ processors (> 0) | 'd' (default " | Processors
+			 | ") ] [ batch (> 0) | 'd' (default " | Batch
+			 | ") ] [ buffer size (>= 0) | 'd' (default " | BufSize
+			 | ") ]" ;
+		exit( EXIT_FAILURE );
+	} // switch
+
+    
+    executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true };
+
+    printf("starting\n");
+
+    start_actor_system( e );
+
+    printf("started\n");
+
+    d_actor actors[ Actors ];
+
+	for ( i; Actors ) {
+		actors[i] | shared_msg;
+	} // for
+
+    printf("stopping\n");
+
+    stop_actor_system();
+
+    printf("stopped\n");
+
+    return 0;
+}
Index: tests/concurrent/actors/matrix.cfa
===================================================================
--- tests/concurrent/actors/matrix.cfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ tests/concurrent/actors/matrix.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -5,5 +5,5 @@
 #include <stdio.h>
 
-unsigned int xr = 100, xc = 100, yc = 100, Processors = 1; // default values
+unsigned int xr = 500, xc = 500, yc = 500, Processors = 1; // default values
 
 struct derived_actor {
Index: tests/concurrent/actors/static.cfa
===================================================================
--- tests/concurrent/actors/static.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
+++ tests/concurrent/actors/static.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -0,0 +1,71 @@
+#include <actor.hfa>
+#include <fstream.hfa>
+#include <stdlib.hfa>
+#include <string.h>
+#include <stdio.h>
+
+int Times = 1000000;								// default values
+
+struct derived_actor {
+    inline actor;
+};
+void ?{}( derived_actor & this ) { ((actor &)this){}; }
+
+struct derived_msg {
+    inline message;
+    int cnt;
+};
+
+void ?{}( derived_msg & this, int cnt ) {
+    ((message &) this){ Nodelete };
+    this.cnt = cnt;
+}
+void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
+
+
+Allocation receive( derived_actor & receiver, derived_msg & msg ) {
+    if ( msg.cnt >= Times ) {
+        sout | "Done";
+        return Finished;
+    }
+    msg.cnt++;
+    receiver | msg;
+    return Nodelete;
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Times = atoi( argv[1] );
+			if ( Times < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0] | " [ times (> 0) ]";
+		exit( EXIT_FAILURE );
+	} // switch
+
+    printf("starting\n");
+
+    executor e{ 0, 1, 1, false };
+    start_actor_system( e );
+
+    printf("started\n");
+
+    derived_msg msg;
+
+    derived_actor actor;
+
+    actor | msg;
+
+    printf("stopping\n");
+
+    stop_actor_system();
+
+    printf("stopped\n");
+
+    return 0;
+}
Index: tests/concurrent/actors/types.cfa
===================================================================
--- tests/concurrent/actors/types.cfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ tests/concurrent/actors/types.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -5,4 +5,6 @@
 #include <stdio.h>
 #include <mutex_stmt.hfa>
+
+struct dummy_actor { actor a; }; // this won't work since the actor isn't inlined
 
 struct derived_actor {
@@ -26,8 +28,18 @@
 }
 
+Allocation receive( derived_actor & receiver, d_msg & msg ) {
+    return receive( receiver, msg.num );
+}
+
 struct derived_actor2 {
+    struct nested { int i; }; // testing nested before inline
     inline actor;
 };
 static inline void ?{}( derived_actor2 & this ) { ((actor &)this){}; }
+
+Allocation receive( derived_actor2 & receiver, d_msg & msg ) {
+    mutex(sout) sout | msg.num;
+    return Finished;
+}
 
 struct derived_actor3 {
@@ -41,13 +53,4 @@
 };
 static inline void ?{}( d_msg2 & this ) { ((message &)this){}; }
-
-Allocation receive( derived_actor2 & receiver, d_msg & msg ) {
-    mutex(sout) sout | msg.num;
-    return Finished;
-}
-
-Allocation receive( derived_actor & receiver, d_msg & msg ) {
-    return receive( receiver, msg.num );
-}
 
 Allocation receive( derived_actor3 & receiver, d_msg & msg ) {
Index: tests/forall.cfa
===================================================================
--- tests/forall.cfa	(revision 9ef5516c1cc0ba4ac2a785e07996cf39ccdab4f7)
+++ tests/forall.cfa	(revision 6d2af20427737b21ac3888a50590857748d535ad)
@@ -10,17 +10,20 @@
 // Created On       : Wed May  9 08:48:15 2018
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jun  5 10:06:08 2021
-// Update Count     : 36
-//
+// Last Modified On : Sun Feb  5 07:54:43 2023
+// Update Count     : 90
+//
+
+#include <fstream.hfa>
 
 void g1() {
-	forall( T ) T f( T ) {};
-	void f( int ) {};
-	void h( void (*p)(void) ) {};
-
-	int x;
-	void (*y)(void);
-	char z;
-	float w;
+	forall( T ) T f( T p ) { sout | 'f'; return p;  };
+	void f( int p ) { sout | p; };
+	void g( void ) { sout | 'g'; };
+	void h( void (*p)(void) ) { p(); };
+
+	int x = 1;
+	void (*y)(void) = g;
+	char z = 'a';
+	float w = 3.5;
 
 	f( x );
@@ -28,16 +31,21 @@
 	f( z );
 	f( w );
+	h( y );
+	f( y );
 	h( f( y ) );
 }
 
 void g2() {
-	forall( T ) void f( T, T ) {}
-	forall( T, U ) void f( T, U ) {}
+	forall( T ) void f( T, T ) { sout | "fT"; }
+	forall( T, U ) void f( T, U ) { sout | "fTU"; }
 
 	int x;
 	float y;
-	int *z;
-	float *w;
-
+	int * z;
+	float * w;
+
+	f( x, x );
+	f( y, y );
+	f( w, w );
 	f( x, y );
 	f( z, w );
@@ -50,11 +58,16 @@
 
 forall( T )
-void swap( T left, T right ) {
-	T temp = left;
-	left = right;
-	right = temp;
-}
-
-trait sumable( T ) {
+void swap( T & left, T & right ) {						// by reference
+    T temp = left;
+    left = right;
+    right = temp;
+}
+
+forall( T )
+[ T, T ] swap( T i, T j ) {								// by value
+    return [ j, i ];
+}
+
+forall( T ) trait sumable {
 	void ?{}( T &, zero_t );							// 0 literal constructor
 	T ?+?( T, T );										// assortment of additions
@@ -64,5 +77,5 @@
 }; // sumable
 
-forall( T | sumable( T ) )						// use trait
+forall( T | sumable( T ) )								// use trait
 T sum( size_t size, T a[] ) {
 	T total = 0;										// initialize by 0 constructor
@@ -72,5 +85,5 @@
 } // sum
 
-forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } )
+forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &, T ); } )
 T twice( T t ) {
 	return t + t;
@@ -82,12 +95,17 @@
 }
 
-int fred() {
-	int x = 1, y = 2, a[10];
+void fred() {
+	int x = 1, y = 2, a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 	float f;
 
+	sout | x | y;
 	swap( x, y );
-	twice( x );
+	sout | x | y | nl | swap( x, y );
+	// [ x, y ] = swap( y, x );
+	sout | twice( ' ' ) | ' ' | twice( 0hh ) | twice( 1h ) | twice( 0n ) | twice( 2 )
+		 | twice( 3.2f ) | twice( 3.2 ) | twice( 3.2d ) | twice( 3.2+1.5i ) | twice( x );
 	f = min( 4.0, 3.0 );
-	sum( 10, a );
+	sout | f | min( 4.0, 3.0 );
+	sout | sum( 10, a );
 }
 
@@ -186,8 +204,8 @@
 
 forall( T ) {
-	extern "C" {
+//	extern "C" {
 		struct SS { T t; };
-		T foo( T ) {}
-	}
+		T foo( T p ) { return p; }
+//	}
 }
 
@@ -195,8 +213,9 @@
 W(int,int) w;
 
-int jane() {
+void jane() {
 //	int j = bar( 3, 4 );
 	int k = baz( 3, 4, 5 );
 	int i = foo( 3 );
+	sout | k | i;
 }
 
@@ -211,4 +230,5 @@
 	T t;
 	T t2 = t;
+	sout | &tr | tp;
 }
 
@@ -242,5 +262,8 @@
 
 int main( void ) {
-    #pragma GCC warning "Compiled"                      // force non-empty .expect file, NO TABS!!!
+	g1();
+	g2();
+	fred();
+	jane();
 }
 
