put cpp examples in example_cpp, debugged `FIND`, making example for type
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sat, 29 Mar 2025 15:12:11 +0000 (15:12 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sat, 29 Mar 2025 15:12:11 +0000 (15:12 +0000)
55 files changed:
developer/cc๐Ÿ–‰/Binding.lib.c [new file with mode: 0644]
developer/cc๐Ÿ–‰/Core.lib.c
developer/cc๐Ÿ–‰/FG.lib.c [deleted file]
developer/cc๐Ÿ–‰/N16.lib.c [deleted file]
developer/cc๐Ÿ–‰/N32.lib.c [deleted file]
developer/cc๐Ÿ–‰/N64.lib.c [deleted file]
developer/cc๐Ÿ–‰/N8.lib.c [deleted file]
developer/cc๐Ÿ–‰/TM.lib.c
developer/cc๐Ÿ–‰/TM_scratch.c [deleted file]
developer/cc๐Ÿ–‰/cpp_ext_0.c
developer/cc๐Ÿ–‰/cpp_ext_1.c
developer/cc๐Ÿ–‰/environment.h [deleted file]
developer/cc๐Ÿ–‰/test_setup.cli.c [deleted file]
developer/cc๐Ÿ–‰/update.lib.c [deleted file]
developer/deprecated๐Ÿ–‰/2025-03-29/N16.lib.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/N32.lib.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/N64.lib.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/N8.lib.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/TM_scratch.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/environment.h [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/test_setup.cli.c [new file with mode: 0644]
developer/deprecated๐Ÿ–‰/2025-03-29/update.lib.c [new file with mode: 0644]
developer/document๐Ÿ–‰/cpp_evaluation.org
developer/example/0_readme.org [new file with mode: 0644]
developer/example/bespoke_type.cli.c [new file with mode: 0644]
developer/example/cpp_ext_0.c [deleted file]
developer/example/cpp_ext_1.c [deleted file]
developer/example/example_A.c [deleted file]
developer/example/example_eval.c [deleted file]
developer/example/example_grow.c [deleted file]
developer/example/example_grow2.c [deleted file]
developer/example/example_recurse.c [deleted file]
developer/example/try_1_exists.c [deleted file]
developer/example/try_2_connectors.c [deleted file]
developer/example/try_3_eq.c [deleted file]
developer/example/try_4_if.c [deleted file]
developer/example/try_5_access.c [deleted file]
developer/example/try_6_list.c [deleted file]
developer/example_cpp/.githolder [new file with mode: 0644]
developer/example_cpp/0_readme.org [new file with mode: 0644]
developer/example_cpp/cpp_ext_0.c [new file with mode: 0644]
developer/example_cpp/cpp_ext_1.c [new file with mode: 0644]
developer/example_cpp/example_A.c [new file with mode: 0644]
developer/example_cpp/example_eval.c [new file with mode: 0644]
developer/example_cpp/example_grow.c [new file with mode: 0644]
developer/example_cpp/example_grow2.c [new file with mode: 0644]
developer/example_cpp/example_recurse.c [new file with mode: 0644]
developer/example_cpp/try_1_exists.c [new file with mode: 0644]
developer/example_cpp/try_2_connectors.c [new file with mode: 0644]
developer/example_cpp/try_3_eq.c [new file with mode: 0644]
developer/example_cpp/try_4_if.c [new file with mode: 0644]
developer/example_cpp/try_5_access.c [new file with mode: 0644]
developer/example_cpp/try_6_list.c [new file with mode: 0644]
developer/tool๐Ÿ–‰/make
developer/tool๐Ÿ–‰/makefile

diff --git a/developer/cc๐Ÿ–‰/Binding.lib.c b/developer/cc๐Ÿ–‰/Binding.lib.c
new file mode 100644 (file)
index 0000000..67e7082
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+Template parameters:
+
+  BindingยทTYPE - Type used to name the binding struct. Binding struct instances get passed as arguments to functions etc.
+
+*/
+
+
+//--------------------------------------------------------------------------------
+// Interface 
+
+// once per translation unit
+#ifndef BindingยทTYPE_LIST
+#define BindingยทTYPE_LIST
+
+  #define BindingยทDEBUG
+  #ifdef BindingยทDEBUG
+    #include <stdio.h>
+  #endif
+
+  #include "cpp_ext.c"
+  #include "Core.lib.c"
+
+#endif
+
+// once per BindingยทTYPE value
+#pragma message( "before gate" )
+#pragma message( STR_VAL(BindingยทTYPE) )
+#ifdef BindingยทTYPE
+#if ! FIND_ITEM( BindingยทTYPE ,BindingยทTYPE_LIST )
+#pragma message( "after gate" )
+#pragma message( STR_VAL(BindingยทTYPE) )
+
+  //this is what it takes to append to a list in cpp ...
+  #undef TEMP
+  #define TEMP BindingยทTYPE_LIST ,BindingยทTYPE
+  #undef BindingยทTYPE_LIST
+  #define BindingยทTYPE_LIST TEMP
+
+  // a simplifying naming convention
+  #define Binding         ฮž(BindingยทTYPE)
+  #define BindingยทFG      ฮž(BindingยทTYPE ,FG)
+  #define BindingยทTableau ฮž(BindingยทTYPE ,Tableau)
+#if 0
+
+  // binds a tableau and Binding table instance together
+  // as a convention, we name the binding after the Type
+  typedef struct BindingยทFG BindingยทFG;
+  typedef struct BindingยทTableau BindingยทTableau;
+  typedef struct{
+    BindingยทFG *fg;
+    BindingยทTableau *tableau;
+  } Binding;
+
+  inline void Bindingยทwellformed_binding(Binding b){
+    #ifdef BindingยทDEBUG
+      CoreยทGuardยทinit_count(chk);
+      CoreยทGuardยทfg.check(&chk, 1, b.fg,      "NULL fg table");
+      CoreยทGuardยทfg.check(&chk, 1, b.tableau, "NULL tableau");
+      CoreยทGuardยทassert(chk);
+    #endif
+  }
+
+  /*
+    usage e.g.: Bindingยทcall(tm, function_name, arg1, arg2, ...)
+    Expands to: (tm.fg->function_name)(tm ,arg1 ,arg2, ...)
+
+    note the use of the comma operator to return the result from the b.fg->fn call
+  */
+  #define Bindingยทcall(b, fn, ...) \
+    ( Bindingยทwellformed_binding(b) ,b.fg->fn(b, ##__VA_ARGS__) )
+
+
+
+#endif
+
+#endif
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+//   Binding has no implementation
+
+#ifdef IMPLEMENTATION
+
+  //----------------------------------------
+  // implementation to go into the lib.a file
+  //----------------------------------------
+  #ifndef LOCAL
+  #endif //#ifndef LOCAL
+
+  //----------------------------------------
+  // implementation to go at the bottom of the translation unit
+  //----------------------------------------
+  #ifdef LOCAL
+  #endif // #ifdef LOCAL
+
+#endif // IMPLEMENTATION
+
+//--------------------------------------------------------------------------------
+// template variables work once
+
+#undef BindingยทTYPE
index 3e78126..031fd69 100644 (file)
 
 */
 
-#define CoreยทDEBUG
-#ifdef FGยทDEBUG
-  #include <stdio.h>
-#endif
-
-#ifndef FACE
-#define CoreยทIMPLEMENTATION
-#define FACE
-#endif 
-
 //--------------------------------------------------------------------------------
-// Interface
+// Interface 
 
 #ifndef CoreยทFACE
 #define CoreยทFACE
 
+  #define CoreยทDEBUG
+  #ifdef FGยทDEBUG
+    #include <stdio.h>
+  #endif
+
   #include <stdint.h>
+  #include <stdbool.h>
   #include <stddef.h>
+  #include "cpp_ext.c"
 
   //----------------------------------------
   // memory interface
   //----------------------------------------
 
-    // Define a namespace.
-    // #define _ฮž(a ,b) a##ยท##b
-    /// #define ฮž(a ,b) _ฮž(a ,b)
-    #include <xi.c>
-
     // extent is the maximum index in an address space, tape or area, the doted
     // unit is the cell type.
-    typedef extent_tยทAU size_t
+    typedef size_t extent_tยทAU;
     #define extent_ofยทAU(x) (sizeof(x) - 1)
-
     // Funny, we seldom check for this, perhaps that matters on some tiny machine.
     #define extentยทAU_address_space ~(uintptr)0;
 
     // addressable unit for the machine
     // C language standard left this undefined. AToW industry uses uint8_t.
-    typedef AU  uint8_t;
-    typedef AU2 uint16_t;
-    typedef AU4 uint32_t;
-    typedef AU8 uint64_t;
+    typedef  uint8_t AU ;
+    typedef uint16_t AU2;
+    typedef uint32_t AU4;
+    typedef uint64_t AU8;
 
-    const AU  AU_max  = (~(AU)0);
-    const AU2 AU2_max = (~(AU2)0);
-    const AU4 AU4_max = (~(AU4)0);
-    const AU8 AU8_max = (~(AU8)0);
+    const AU  AU_MAX  = (~(AU)0);
+    const AU2 AU2_MAX = (~(AU2)0);
+    const AU4 AU4_MAX = (~(AU4)0);
+    const AU8 AU8_MAX = (~(AU8)0);
 
     // ask the compiler what this is
     // when using enums we get this whether we want it or not
-    typedef WU unsigned int;
-    const WU WU_max = (~(WU)0);
+    typedef unsigned int WU;
+    const WU WU_MAX = (~(WU)0);
 
   //----------------------------------------
   // flag facility, argument guard facility
       else return CoreยทStatusยทon_track;
     #define CoreยทGuardยทassert(chk) assert(!chk.flag);
 
-  //----------------------------------------
-  // Macro to call a function in the FG table with debug checks
-  // Usage: FGยทcall(tm, function_name, arg1, arg2, ...)
-  // Expands to: ((tm)->fg->function_name)((tm)->t, arg1, arg2, ...)
-  // With debug checks for NULL pointers when FGยทDEBUG is defined
-  //----------------------------------------
-
-    typedef struct FGยทFG;
-    typedef struct FGยทTableau;
-
-    typedef struct{
-      FGยทFG *fg;
-      FGยทTableau *tableau;
-    } FGยทBinding;
-
-    inline void FGยทwellformed_binding(FGยทBinding b) {
-      #ifdef FGยทDEBUG
-        CoreยทGuardยทinit_count(chk);
-        CoreยทGuardยทfg.check(&chk, 1, b->fg,      "NULL fg table");
-        CoreยทGuardยทfg.check(&chk, 1, b->tableau, "NULL tableau");
-        CoreยทGuardยทassert(chk);
-      #endif
-    }
-
-    // note the use of the comma operator to return the result from b.fg->fn
-    #define FGยทcall(b, fn, ...) \
-      ( \
-         FGยทwellformed_binding(b)               \
-        ,b.fg->fn(b.tableau, ##__VA_ARGS__ )   \
-        ) 
-
-
   //----------------------------------------
   // functions interface
   //----------------------------------------
     typedef struct{
       CoreยทStatus (*on_track)();
       CoreยทStatus (*derailed)();
-      CoreยทStatus (*is_aligned)(AU *p ,extentยทAU alignment ,bool *flag);
-      CoreยทStatus (*round_down)(AU *p ,extentยทAU alignment ,AU **result);
-      CoreยทStatus (*round_up)(AU *p ,extentยทAU alignment ,AU **result);
+      CoreยทStatus (*is_aligned)(AU *p ,extent_tยทAU alignment ,bool *flag);
+      CoreยทStatus (*round_down)(AU *p ,extent_tยทAU alignment ,AU **result);
+      CoreยทStatus (*round_up)(AU *p ,extent_tยทAU alignment ,AU **result);
     } CoreยทF;
     Local CoreยทF Coreยทf;
 
-#endif // FACE
+#endif // #if COREยทFACE
 
 
 //--------------------------------------------------------------------------------
 // Implementation
 
-#ifdef CoreยทIMPLEMENTATION
+#ifdef IMPLEMENTATION
 
   //--------------------------------------------------------------------------------
   // implementation to go into the lib.a file
   //
-    #ifndef LOCAL
-    #endif 
+  #ifndef LOCAL
+  #endif 
 
   //--------------------------------------------------------------------------------
   #ifdef LOCAL
diff --git a/developer/cc๐Ÿ–‰/FG.lib.c b/developer/cc๐Ÿ–‰/FG.lib.c
deleted file mode 100644 (file)
index 6d659fa..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-Template parameters:
-
-  FGยทType - Type used to name the binding struct. Binding struct instances get passed as arguments to functions etc.
-
-Template variables are _use once_ per #include. (They are #undef at the bottom of this file.)
-       
-*/
-
-#include "cpp_ext.c"
-
-#ifndef FACE
-#define FGยทIMPLEMENTATION
-#define FACE
-#endif 
-
-//--------------------------------------------------------------------------------
-// Interface 
-
-// once per translation unit
-#ifndef FGยทTYPE_LIST
-#define FGยทTYPE_LIST
-
-  #define FGยทDEBUG
-  #ifdef FGยทDEBUG
-    #include <stdio.h>
-  #endif
-
-#endif
-
-// once per FGยทTYPE value
-#if ! FIND_ITEM( FGยทTYPE ,FGยทTYPE_LIST )
-#define FGยทTYPE_LIST APPEND(FGยทTYPE_LIST ,FGยทTYPE)
-
-  // a simplifying naming convention
-  #define FGยทBinding ฮž(FGยทType)
-  #define FGยทFG      ฮž(FGยทType ,FG)
-  #define FGยทTableau ฮž(FGยทType ,Tableau)
-
-  // as a convention, we name the binding after the type
-  typedef struct{
-    FGยทFG *fg;
-    FGยทTableau *tableau;
-  } FGยทBinding;
-
-  // binds a tableau and FG tabel instance together
-  inline void FGยทwellformed_binding(FGยทBinding b){
-    #ifdef FGยทDEBUG
-      FGยทGuardยทinit_count(chk);
-      FGยทGuardยทfg.check(&chk, 1, b.fg,      "NULL fg table");
-      FGยทGuardยทfg.check(&chk, 1, b.tableau, "NULL tableau");
-      FGยทGuardยทassert(chk);
-    #endif
-  }
-
-  /*
-    usage e.g.: FGยทcall(tm, function_name, arg1, arg2, ...)
-    Expands to: (tm.fg->function_name)((tm)->t, arg1, arg2, ...)
-
-    note the use of the comma operator to return the result from the b.fg->fn call
-  */
-  #define FGยทcall(b, fn, ...) \
-    ( FGยทwellformed_binding(b) ,b.fg->fn(b.tableau, ##__VA_ARGS__) )
-
-#endif // FACE
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef FGยทIMPLEMENTATION
-
-  //----------------------------------------
-  // implementation to go into the lib.a file
-  //----------------------------------------
-  #ifndef LOCAL
-  #endif //#ifndef LOCAL
-
-  //----------------------------------------
-  // implementation to go at the bottom of the source file
-  //----------------------------------------
-  #ifdef LOCAL
-  #endif // #ifdef LOCAL
-
-#endif // IMPLEMENTATION
-
-// template variables are use once
-#undef FGยทType
-
diff --git a/developer/cc๐Ÿ–‰/N16.lib.c b/developer/cc๐Ÿ–‰/N16.lib.c
deleted file mode 100644 (file)
index 561b43d..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
-  N16 - a processor native type
-
-  For binary operations:  a op b -> c
-
-  See the document on the proper use of the Natural types.
-
-  On the subject of multiple pointers indicating the same location in memory:
-
-  When a routine has multiple results, and one or more of the result location
-  pointers point to the same storage, the routine will either return an error
-  status, or have defined behavior.
-
-  When a routine has multiple operands, in any combination, those
-  pointers can point to the same location, and the routine will
-  function as advertised.
-
-  When an operand functions as both an input and a result, perhaps due
-  to a result pointer pointing to the same place as an operand
-  pointer, the routine will function as advertised. (Internally the
-  routine might make a temporary copy of the operand to accomplish
-  this.)
-*/
-
-#define N16ยทDEBUG
-
-#ifndef FACE
-#define N16ยทIMPLEMENTATION
-#define FACE
-#endif
-
-//--------------------------------------------------------------------------------
-// Interface
-
-#ifndef N16ยทFACE
-#define N16ยทFACE
-
-  #include <stdint.h>
-  #include <stdbool.h>
-  #include <stdarg.h>
-  #include <stdlib.h>
-
-  //----------------------------------------
-  // Instance Data (Declaration Only)
-
-  typedef uint16_t Extent;
-  typedef uint16_t Digit;
-
-  typedef struct N16ยทT N16ยทT;
-
-  extern N16ยทT *N16ยทzero;
-  extern N16ยทT *N16ยทone;
-  extern N16ยทT *N16ยทall_one_bit;
-  extern N16ยทT *N16ยทlsb;
-  extern N16ยทT *N16ยทmsb;
-
-  //----------------------------------------
-  // Return/Error Status and handlers
-
-  typedef enum{
-    N16ยทStatusยทok = 0
-   ,N16ยทStatusยทoverflow = 1
-   ,N16ยทStatusยทaccumulator1_overflow = 2
-   ,N16ยทStatusยทcarry = 3
-   ,N16ยทStatusยทborrow = 4
-   ,N16ยทStatusยทundefined_divide_by_zero = 5
-   ,N16ยทStatusยทundefined_modulus_zero = 6
-   ,N16ยทStatusยทgt_max_shift_count = 7
-   ,N16ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
-   ,N16ยทStatusยทone_word_product = 9
-   ,N16ยทStatusยทtwo_word_product = 10
-  } N16ยทStatus;
-
-  typedef enum{
-    N16ยทOrder_lt = -1
-   ,N16ยทOrder_eq = 0
-   ,N16ยทOrder_gt = 1
-  } N16ยทOrder;
-
-  typedef N16ยทT *( *N16ยทAllocate_MemoryFault )(Extent);
-
-  //----------------------------------------
-  // Interface
-
-  typedef struct{
-
-    N16ยทT *(*allocate_array_zero)(Extent, N16ยทAllocate_MemoryFault);
-    N16ยทT *(*allocate_array)(Extent, N16ยทAllocate_MemoryFault);
-    void (*deallocate)(N16ยทT*);
-
-    void (*copy)(N16ยทT*, N16ยทT*);
-    void (*bit_and)(N16ยทT*, N16ยทT*, N16ยทT*);
-    void (*bit_or)(N16ยทT*, N16ยทT*, N16ยทT*);
-    void (*bit_complement)(N16ยทT*, N16ยทT*);
-    void (*bit_twos_complement)(N16ยทT*, N16ยทT*);
-    N16ยทOrder (*compare)(N16ยทT*, N16ยทT*);
-    bool (*lt)(N16ยทT*, N16ยทT*);
-    bool (*gt)(N16ยทT*, N16ยทT*);
-    bool (*eq)(N16ยทT*, N16ยทT*);
-    bool (*eq_zero)(N16ยทT*);
-    N16ยทStatus (*accumulate)(N16ยทT *accumulator1 ,N16ยทT *accumulator0 ,...);
-    N16ยทStatus (*add)(N16ยทT*, N16ยทT*, N16ยทT*);
-    bool (*increment)(N16ยทT *a);
-    N16ยทStatus (*subtract)(N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*multiply)(N16ยทT*, N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*divide)(N16ยทT*, N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*modulus)(N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*shift_left)(Extent, N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*shift_right)(Extent, N16ยทT*, N16ยทT*, N16ยทT*);
-    N16ยทStatus (*arithmetic_shift_right)(Extent, N16ยทT*, N16ยทT*);
-
-    N16ยทT* (*access)(N16ยทT*, Extent);
-    void (*from_uint32)(N16ยทT *destination ,uint32_t value);
-  } N16ยทM;
-
-  Local const N16ยทM N16ยทm; // initialized in the LOCAL section
-
-#endif
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef N16ยทIMPLEMENTATION
-
-  // this part goes into the library
-  #ifndef LOCAL
-
-    #include <stdarg.h>
-    #include <stdlib.h>
-
-    struct N16ยทT{
-      Digit d0;
-    };
-
-    N16ยทT N16ยทconstant[4] = {
-    {.d0 = 0},
-    {.d0 = 1},
-    {.d0 = ~(uint16_t)0},
-    {.d0 = 1 << 15}
-    };
-
-    N16ยทT *N16ยทzero = &N16ยทconstant[0];
-    N16ยทT *N16ยทone = &N16ยทconstant[1];
-    N16ยทT *N16ยทall_one_bit = &N16ยทconstant[2];
-    N16ยทT *N16ยทmsb = &N16ยทconstant[3];
-    N16ยทT *N16ยทlsb = &N16ยทconstant[1];
-
-    // the allocate an array of N16
-    N16ยทT *N16ยทallocate_array(Extent extent ,N16ยทAllocate_MemoryFault memory_fault){
-      N16ยทT *instance = malloc((extent + 1) * sizeof(N16ยทT));
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    N16ยทT *N16ยทallocate_array_zero(Extent extent ,N16ยทAllocate_MemoryFault memory_fault){
-      N16ยทT *instance = calloc(extent + 1, sizeof(N16ยทT));
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    void N16ยทdeallocate(N16ยทT *unencumbered){
-      free(unencumbered);
-    }
-
-
-  #endif
-
-  // This part is included after the library user's code
-  #ifdef LOCAL
-
-    // instance
-
-    struct N16ยทT{
-      Digit d0;
-    };
-
-    // temporary variables
-    Local N16ยทT N16ยทt[4];
-
-    // allocation 
-
-    extern N16ยทT *N16ยทallocate_array(Extent, N16ยทAllocate_MemoryFault);
-    extern N16ยทT *N16ยทallocate_array_zero(Extent, N16ยทAllocate_MemoryFault);
-    extern void N16ยทdeallocate(N16ยทT *);
-
-    // so the user can access numbers in an array allocation
-    Local N16ยทT* N16ยทaccess(N16ยทT *array ,Extent index){
-      return &array[index];
-    }
-
-    Local void N16ยทfrom_uint32(N16ยทT *destination ,uint32_t value){
-      if(destination == NULL) return;
-      destination->d0 = (uint16_t)(value & 0xFFFF);
-    }
-
-    // copy, convenience copy
-
-    Local void N16ยทcopy(N16ยทT *destination ,N16ยทT *source){
-      if(source == destination) return;
-      *destination = *source;
-    }
-
-    Local void N16ยทset_to_zero(N16ยทT *instance){
-      instance->d0 = 0;
-    }
-
-    Local void N16ยทset_to_one(N16ยทT *instance){
-      instance->d0 = 1;
-    }
-
-    // bit operations
-
-    Local void N16ยทbit_and(N16ยทT *result, N16ยทT *a, N16ยทT *b){
-      result->d0 = a->d0 & b->d0;
-    }
-
-    Local void N16ยทbit_or(N16ยทT *result, N16ยทT *a, N16ยทT *b){
-      result->d0 = a->d0 | b->d0;
-    }
-
-    Local void N16ยทbit_complement(N16ยทT *result, N16ยทT *a){
-      result->d0 = ~a->d0;
-    }
-
-    Local void N16ยทbit_twos_complement(N16ยทT *result ,N16ยทT *a){
-      result->d0 = (uint16_t)(~a->d0 + 1);
-    }
-
-    // test functions
-
-    Local N16ยทOrder N16ยทcompare(N16ยทT *a, N16ยทT *b){
-      if(a->d0 < b->d0) return N16ยทOrder_lt;
-      if(a->d0 > b->d0) return N16ยทOrder_gt;
-      return N16ยทOrder_eq;
-    }
-
-    Local bool N16ยทlt(N16ยทT *a ,N16ยทT *b){
-      return a->d0 < b->d0;
-    }    
-
-    Local bool N16ยทgt(N16ยทT *a ,N16ยทT *b){
-      return a->d0 > b->d0;
-    }    
-
-    Local bool N16ยทeq(N16ยทT *a ,N16ยทT *b){
-      return a->d0 == b->d0;
-    }    
-
-    Local bool N16ยทeq_zero(N16ยทT *a){
-      return a->d0 == 0;
-    }    
-
-    // arithmetic operations
-
-    Local N16ยทStatus N16ยทaccumulate(N16ยทT *accumulator1 ,N16ยทT *accumulator0 ,...){
-
-      va_list args;
-      va_start(args ,accumulator0);
-      uint32_t sum = accumulator0->d0;
-      uint32_t carry = 0;
-      N16ยทT *current;
-
-      while( (current = va_arg(args ,N16ยทT*)) ){
-        sum += current->d0;
-        if(sum < current->d0){
-          (carry)++;
-          if(carry == 0){
-            va_end(args);
-            return N16ยทStatusยทaccumulator1_overflow;
-          }
-        }
-      }
-      va_end(args);
-
-      accumulator1->d0 = (uint16_t)carry;
-      return N16ยทStatusยทok;
-    }
-
-    Local N16ยทStatus N16ยทadd(N16ยทT *sum ,N16ยทT *a ,N16ยทT *b){
-      uint32_t result = (uint32_t)a->d0 + (uint32_t)b->d0;
-      sum->d0 = (uint16_t)(result & 0xFFFF);
-      return (result >> 16) ? N16ยทStatusยทcarry : N16ยทStatusยทok;
-    }
-
-    Local bool N16ยทincrement(N16ยทT *a){
-      a->d0++;
-      return (a->d0 == 0);
-    }
-
-    Local N16ยทStatus N16ยทsubtract(N16ยทT *difference ,N16ยทT *a ,N16ยทT *b){
-      uint32_t diff = (uint32_t)a->d0 - (uint32_t)b->d0;
-      difference->d0 = (uint16_t)(diff & 0xFFFF);
-      return (diff > a->d0) ? N16ยทStatusยทborrow : N16ยทStatusยทok;
-    }
-
-    Local N16ยทStatus N16ยทmultiply(N16ยทT *product1 ,N16ยทT *product0 ,N16ยทT *a ,N16ยทT *b){
-      uint32_t product = (uint32_t)a->d0 * (uint32_t)b->d0;
-      product0->d0 = (uint16_t)(product & 0xFFFF);
-      product1->d0 = (uint16_t)((product >> 16) & 0xFFFF);
-
-      if(product1->d0 == 0) return N16ยทStatusยทone_word_product;
-      return N16ยทStatusยทtwo_word_product;
-    }
-
-    Local N16ยทStatus N16ยทdivide(N16ยทT *remainder ,N16ยทT *quotient ,N16ยทT *a ,N16ยทT *b){
-      if(b->d0 == 0) return N16ยทStatusยทundefined_divide_by_zero;
-
-      uint32_t dividend = a->d0;
-      uint32_t divisor = b->d0;
-      quotient->d0 = (uint16_t)(dividend / divisor);
-      remainder->d0 = (uint16_t)(dividend - (quotient->d0 * divisor));
-
-      return N16ยทStatusยทok;
-    }
-
-    Local N16ยทStatus N16ยทmodulus(N16ยทT *remainder ,N16ยทT *a ,N16ยทT *b){
-      if(b->d0 == 0) return N16ยทStatusยทundefined_modulus_zero;
-      uint32_t dividend = a->d0;
-      uint32_t divisor = b->d0;
-      uint32_t q = dividend / divisor;
-      remainder->d0 = (uint16_t)(dividend - (q * divisor));
-      return N16ยทStatusยทok;
-    }
-
-    // bit motion
-
-    typedef uint16_t (*ShiftOp)(uint16_t, uint16_t);
-
-    Local uint16_t shift_left_op(uint16_t value, uint16_t amount){
-      return value << amount;
-    }
-
-    Local uint16_t shift_right_op(uint16_t value, uint16_t amount){
-      return (uint16_t)(value >> amount);
-    }
-
-    Local N16ยทStatus N16ยทshift
-    (
-     uint16_t shift_count
-     ,N16ยทT *spill
-     ,N16ยทT *operand
-     ,N16ยทT *fill
-     ,ShiftOp shift_op
-     ,ShiftOp complement_shift_op
-    ){
-
-      if(operand == NULL && spill == NULL) return N16ยทStatusยทok;
-
-      if(operand == NULL){
-        operand = &N16ยทt[0];
-        N16ยทcopy(operand, N16ยทzero);
-      }
-
-      if(shift_count > 15) return N16ยทStatusยทgt_max_shift_count;
-
-      N16ยทT *given_operand = &N16ยทt[1];
-      N16ยทcopy(given_operand, operand);
-
-      operand->d0 = shift_op(given_operand->d0, shift_count);
-      if(fill != NULL){
-        fill->d0 = complement_shift_op(fill->d0, (16 - shift_count));
-        N16ยทbit_or(operand, operand, fill);
-      }
-      if(spill != NULL){
-        spill->d0 = shift_op(spill->d0, shift_count);
-        spill->d0 += complement_shift_op(given_operand->d0, (16 - shift_count));
-      }
-
-      return N16ยทStatusยทok;
-    }
-
-    Local N16ยทStatus 
-    N16ยทshift_left(uint16_t shift_count, N16ยทT *spill, N16ยทT *operand, N16ยทT *fill){
-      return N16ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
-    }
-
-    Local N16ยทStatus 
-    N16ยทshift_right(uint16_t shift_count, N16ยทT *spill, N16ยทT *operand, N16ยทT *fill){
-      return N16ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
-    }
-
-    Local N16ยทStatus 
-    N16ยทarithmetic_shift_right(uint16_t shift_count, N16ยทT *operand, N16ยทT *spill){
-
-      if(shift_count > 15) return N16ยทStatusยทgt_max_shift_count;
-
-      if(operand == NULL){
-        operand = &N16ยทt[0];
-        N16ยทcopy(operand, N16ยทzero);
-      }
-
-      N16ยทT *fill = (operand->d0 & 0x8000) ? N16ยทall_one_bit : N16ยทzero;
-      return N16ยทshift_right(shift_count, spill, operand, fill);
-    }
-
-    Local const N16ยทM N16ยทm = {
-
-      .allocate_array = N16ยทallocate_array
-     ,.allocate_array_zero = N16ยทallocate_array_zero
-     ,.deallocate = N16ยทdeallocate
-
-     ,.copy = N16ยทcopy
-     ,.bit_and = N16ยทbit_and
-     ,.bit_or = N16ยทbit_or
-     ,.bit_complement = N16ยทbit_complement
-     ,.bit_twos_complement = N16ยทbit_twos_complement
-     ,.compare = N16ยทcompare
-     ,.lt = N16ยทlt
-     ,.gt = N16ยทgt
-     ,.eq = N16ยทeq
-     ,.eq_zero = N16ยทeq_zero
-     ,.accumulate = N16ยทaccumulate
-     ,.add = N16ยทadd
-     ,.increment = N16ยทincrement
-     ,.subtract = N16ยทsubtract
-     ,.multiply = N16ยทmultiply
-     ,.divide = N16ยทdivide
-     ,.modulus = N16ยทmodulus
-     ,.shift_left = N16ยทshift_left
-     ,.shift_right = N16ยทshift_right
-     ,.arithmetic_shift_right = N16ยทarithmetic_shift_right
-
-     ,.access = N16ยทaccess
-     ,.from_uint32 = N16ยทfrom_uint32
-    };
-
-  #endif
-
-#endif
diff --git a/developer/cc๐Ÿ–‰/N32.lib.c b/developer/cc๐Ÿ–‰/N32.lib.c
deleted file mode 100644 (file)
index ccb3411..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
-  N32 - a processor native type
-
-  For binary operations:  a op b -> c
-
-  See the document on the proper use of the Natural types.
-
-  On the subject of multiple pointers indicating the same location in memory:
-
-  When a routine has multiple results, and one or more of the result location
-  pointers point to the same storage, the routine will either return an error
-  status, or have defined behavior.
-
-  When a routine has multiple operands, in any combination, those
-  pointers can point to the same location, and the routine will
-  function as advertised.
-
-  When an operand functions as both an input and a result, perhaps due
-  to a result pointer pointing to the same place as an operand
-  pointer, the routine will function as advertised. (Internally the
-  routine might make a temporary copy of the operand to accomplish
-  this.)
-
-*/
-
-#define N32ยทDEBUG
-
-#ifndef FACE
-#define N32ยทIMPLEMENTATION
-#define FACE
-#endif
-
-//--------------------------------------------------------------------------------
-// Interface
-
-#ifndef N32ยทFACE
-#define N32ยทFACE
-
-  #include <stdint.h>
-  #include <stdbool.h>
-  #include <stdarg.h>
-  #include <stdlib.h>
-
-  //----------------------------------------
-  // Instance Data (Declaration Only)
-
-  typedef uint32_t Extent;
-  typedef uint32_t Digit;
-
-  typedef struct N32ยทT N32ยทT;
-
-  extern N32ยทT *N32ยทzero;
-  extern N32ยทT *N32ยทone;
-  extern N32ยทT *N32ยทall_one_bit;
-  extern N32ยทT *N32ยทlsb;
-  extern N32ยทT *N32ยทmsb;
-
-  //----------------------------------------
-  // Return/Error Status and handlers
-
-  typedef enum{
-    N32ยทStatusยทok = 0
-    ,N32ยทStatusยทoverflow = 1
-    ,N32ยทStatusยทaccumulator1_overflow = 2
-    ,N32ยทStatusยทcarry = 3
-    ,N32ยทStatusยทborrow = 4
-    ,N32ยทStatusยทundefined_divide_by_zero = 5
-    ,N32ยทStatusยทundefined_modulus_zero = 6
-    ,N32ยทStatusยทgt_max_shift_count = 7
-    ,N32ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
-    ,N32ยทStatusยทone_word_product = 9
-    ,N32ยทStatusยทtwo_word_product = 10
-  } N32ยทStatus;
-
-  typedef enum{
-    N32ยทOrder_lt = -1
-    ,N32ยทOrder_eq = 0
-    ,N32ยทOrder_gt = 1
-  } N32ยทOrder;
-
-  typedef N32ยทT *( *N32ยทAllocate_MemoryFault )(Extent);
-
-  //----------------------------------------
-  // Interface
-
-  typedef struct{
-
-    N32ยทT *(*allocate_array_zero)(Extent, N32ยทAllocate_MemoryFault);
-    N32ยทT *(*allocate_array)(Extent, N32ยทAllocate_MemoryFault);
-    void (*deallocate)(N32ยทT*);
-
-    void (*copy)(N32ยทT*, N32ยทT*);
-    void (*bit_and)(N32ยทT*, N32ยทT*, N32ยทT*);
-    void (*bit_or)(N32ยทT*, N32ยทT*, N32ยทT*);
-    void (*bit_complement)(N32ยทT*, N32ยทT*);
-    void (*bit_twos_complement)(N32ยทT*, N32ยทT*);
-    N32ยทOrder (*compare)(N32ยทT*, N32ยทT*);
-    bool (*lt)(N32ยทT*, N32ยทT*);
-    bool (*gt)(N32ยทT*, N32ยทT*);
-    bool (*eq)(N32ยทT*, N32ยทT*);
-    bool (*eq_zero)(N32ยทT*);
-    N32ยทStatus (*accumulate)(N32ยทT *accumulator1 ,N32ยทT *accumulator0 ,...);
-    N32ยทStatus (*add)(N32ยทT*, N32ยทT*, N32ยทT*);
-    bool (*increment)(N32ยทT *a);
-    N32ยทStatus (*subtract)(N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*multiply)(N32ยทT*, N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*divide)(N32ยทT*, N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*modulus)(N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*shift_left)(Extent, N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*shift_right)(Extent, N32ยทT*, N32ยทT*, N32ยทT*);
-    N32ยทStatus (*arithmetic_shift_right)(Extent, N32ยทT*, N32ยทT*);
-
-    N32ยทT* (*access)(N32ยทT*, Extent);
-    void (*from_uint32)(N32ยทT *destination ,uint32_t value);
-  } N32ยทM;
-
-  Local const N32ยทM N32ยทm; // initialized in the LOCAL section
-
-#endif
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef N32ยทIMPLEMENTATION
-
-  // this part goes into the library
-  #ifndef LOCAL
-
-    #include <stdarg.h>
-    #include <stdlib.h>
-
-    struct N32ยทT{
-      Digit d0;
-    };
-
-    N32ยทT N32ยทconstant[4] = {
-      {.d0 = 0},
-      {.d0 = 1},
-      {.d0 = ~(uint32_t)0},
-      {.d0 = 1 << 31}
-    };
-
-    N32ยทT *N32ยทzero = &N32ยทconstant[0];
-    N32ยทT *N32ยทone = &N32ยทconstant[1];
-    N32ยทT *N32ยทall_one_bit = &N32ยทconstant[2];
-    N32ยทT *N32ยทmsb = &N32ยทconstant[3];
-    N32ยทT *N32ยทlsb = &N32ยทconstant[1];
-
-    // the allocate an array of N32
-    N32ยทT *N32ยทallocate_array(Extent extent ,N32ยทAllocate_MemoryFault memory_fault){
-      N32ยทT *instance = malloc((extent + 1) * sizeof(N32ยทT) );
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    N32ยทT *N32ยทallocate_array_zero(Extent extent ,N32ยทAllocate_MemoryFault memory_fault){
-      N32ยทT *instance = calloc( extent + 1 ,sizeof(N32ยทT) );
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    void N32ยทdeallocate(N32ยทT *unencumbered){
-      free(unencumbered);
-    }
-
-  #endif
-
-  // This part is included after the library user's code
-  #ifdef LOCAL
-
-    // instance
-
-    struct N32ยทT{
-      Digit d0;
-    };
-
-    // temporary variables
-    // making these LOCAL rather than reserving one block in the library is thread safe
-    // allocating a block once is more efficient
-    // library code writes these, they are not on the interface
-
-    Local N32ยทT N32ยทt[4];
-
-
-    // allocation 
-
-    extern N32ยทT *N32ยทallocate_array(Extent, N32ยทAllocate_MemoryFault);
-    extern N32ยทT *N32ยทallocate_array_zero(Extent, N32ยทAllocate_MemoryFault);
-    extern void N32ยทdeallocate(N32ยทT *);
-
-    // so the user can access numbers in an array allocation
-    Local N32ยทT* N32ยทaccess(N32ยทT *array ,Extent index){
-      return &array[index];
-    }
-
-    Local void N32ยทfrom_uint32(N32ยทT *destination ,uint32_t value){
-      if(destination == NULL) return;
-      destination->d0 = value;
-    }
-
-    // copy, convenience copy
-
-    Local void N32ยทcopy(N32ยทT *destination ,N32ยทT *source){
-      if(source == destination) return; // that was easy! 
-      *destination = *source;
-    }
-
-    Local void N32ยทset_to_zero(N32ยทT *instance){
-      instance->d0 = 0;
-    }
-
-    Local void N32ยทset_to_one(N32ยทT *instance){
-      instance->d0 = 1;
-    }
-
-    // bit operations
-
-    Local void N32ยทbit_and(N32ยทT *result, N32ยทT *a, N32ยทT *b){
-      result->d0 = a->d0 & b->d0;
-    }
-
-    // result can be one of the operands
-    Local void N32ยทbit_or(N32ยทT *result, N32ยทT *a, N32ยทT *b){
-      result->d0 = a->d0 | b->d0;
-    }
-
-    // result can the same as the operand
-    Local void N32ยทbit_complement(N32ยทT *result, N32ยทT *a){
-      result->d0 = ~a->d0;
-    }
-
-    // result can the same as the operand
-    Local void N32ยทbit_twos_complement(N32ยทT *result ,N32ยทT *a){
-      result->d0 = ~a->d0 + 1;
-    }
-
-    // test functions
-
-    Local N32ยทOrder N32ยทcompare(N32ยทT *a, N32ยทT *b){
-      if(a->d0 < b->d0) return N32ยทOrder_lt;
-      if(a->d0 > b->d0) return N32ยทOrder_gt;
-      return N32ยทOrder_eq;
-    }
-
-    Local bool N32ยทlt(N32ยทT *a ,N32ยทT *b){
-      return  a->d0 < b->d0;
-    }    
-
-    Local bool N32ยทgt(N32ยทT *a ,N32ยทT *b){
-      return  a->d0 > b->d0;
-    }    
-
-    Local bool N32ยทeq(N32ยทT *a ,N32ยทT *b){
-      return  a->d0 == b->d0;
-    }    
-
-    Local bool N32ยทeq_zero(N32ยทT *a){
-      return  a->d0 == 0;
-    }    
-
-
-    // arithmetic operations
-
-    // For a large number of summands for the lower precision Natural implementations, for accumulate/add/sub, the 'overflow' operand could overflow and thus this routine will halt and return N32ยทStatusยทaccumulator1_overflow
-    //
-    // When accumulator1 and accumulator0 point to the same location, the result is the accumulator1 value.
-    Local N32ยทStatus N32ยทaccumulate(N32ยทT *accumulator1 ,N32ยทT *accumulator0 ,...){
-
-      va_list args;
-      va_start(args ,accumulator0);
-      uint32_t sum = accumulator0->d0;
-      uint32_t carry = 0;
-      N32ยทT *current;
-
-      while( (current = va_arg(args ,N32ยทT *)) ){
-        sum += current->d0;
-        if(sum < current->d0){  // Accumulator1 into carry
-          (carry)++;
-          if(carry == 0){
-            va_end(args);
-            return N32ยทStatusยทaccumulator1_overflow;
-          }
-        }
-      }
-      va_end(args);
-
-      // wipes out prior value of accumulator1
-      accumulator1->d0 = carry;
-
-      return N32ยทStatusยทok;
-    }
-
-    Local N32ยทStatus N32ยทadd(N32ยทT *sum ,N32ยทT *a ,N32ยทT *b){
-      uint64_t result = (uint64_t)a->d0 + (uint64_t)b->d0;
-      sum->d0 = (uint32_t)result;
-      return (result >> 32) ? N32ยทStatusยทcarry : N32ยทStatusยทok;
-    }
-
-    Local bool N32ยทincrement(N32ยทT *a){
-      a->d0++;
-      return a->d0 == 0;
-    }
-
-    Local N32ยทStatus N32ยทsubtract(N32ยทT *difference ,N32ยทT *a ,N32ยทT *b){
-      uint64_t diff = (uint64_t) a->d0 - (uint64_t) b->d0;
-      difference->d0 = (uint32_t)diff;
-      return (diff > a->d0) ? N32ยทStatusยทborrow : N32ยทStatusยทok;
-    }
-
-
-    Local N32ยทStatus N32ยทmultiply(N32ยทT *product1 ,N32ยทT *product0 ,N32ยทT *a ,N32ยทT *b){
-      uint64_t product = (uint64_t)a->d0 * (uint64_t)b->d0;
-      product0->d0 = (uint32_t)product;
-      product1->d0 = (uint32_t)(product >> 32);
-
-      if(product1->d0 == 0) return N32ยทStatusยทone_word_product;
-      return N32ยทStatusยทtwo_word_product;
-    }
-
-    Local N32ยทStatus N32ยทdivide(N32ยทT *remainder ,N32ยทT *quotient ,N32ยทT *a ,N32ยทT *b){
-      if(b->d0 == 0) return N32ยทStatusยทundefined_divide_by_zero; 
-
-      quotient->d0 = a->d0 / b->d0;
-      remainder->d0 = a->d0 - (quotient->d0 * b->d0);
-
-      return N32ยทStatusยทok;
-    }
-
-    Local N32ยทStatus N32ยทmodulus(N32ยทT *remainder ,N32ยทT *a ,N32ยทT *b){
-      if(b->d0 == 0) return N32ยทStatusยทundefined_modulus_zero; 
-      uint32_t quotient = a->d0 / b->d0;
-      remainder->d0 = a->d0 - (quotient * b->d0);
-      return N32ยทStatusยทok;
-    }
-
-    // bit motion
-
-    typedef uint32_t (*ShiftOp)(uint32_t, uint32_t);
-
-    Local uint32_t shift_left_op(uint32_t value, uint32_t amount){
-      return value << amount;
-    }
-
-    Local uint32_t shift_right_op(uint32_t value, uint32_t amount){
-      return value >> amount;
-    }
-
-    // modifies all three of its operands
-    // in the case of duplicate operands this is the order: first modifies operand, then fill, then spill, 
-    Local N32ยทStatus N32ยทshift
-    (
-     uint32_t shift_count
-     ,N32ยทT *spill
-     ,N32ยทT *operand
-     ,N32ยทT *fill
-     ,ShiftOp shift_op
-     ,ShiftOp complement_shift_op
-     ){
-
-      // If no result is needed, return immediately.
-      if(operand == NULL && spill == NULL) return N32ยทStatusยทok;
-
-      // Treat NULL operand as zero.
-      if(operand == NULL){
-        operand = &N32ยทt[0];
-        N32ยทcopy(operand, N32ยทzero);
-      }
-
-      // Shifting more than one word breaks our fill/spill model.
-      if(shift_count > 31) return N32ยทStatusยทgt_max_shift_count;
-
-      // The given operand is still required after it is modified, so we copy it.
-      N32ยทT *given_operand = &N32ยทt[1];
-      N32ยทcopy(given_operand, operand);
-
-      // Perform the shift
-      operand->d0 = shift_op(given_operand->d0, shift_count);
-      if(fill != NULL){
-        fill->d0 = complement_shift_op(fill->d0, (32 - shift_count));
-        N32ยทbit_or(operand, operand, fill);
-      }
-      if(spill != NULL){
-        spill->d0 = shift_op(spill->d0, shift_count);
-        spill->d0 += complement_shift_op(given_operand->d0, (32 - shift_count));
-      }
-
-      return N32ยทStatusยทok;
-    }
-
-    // Define concrete shift functions using valid C function pointers
-    Local N32ยทStatus 
-    N32ยทshift_left(uint32_t shift_count, N32ยทT *spill, N32ยทT *operand, N32ยทT *fill){
-      return N32ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
-    }
-
-    Local N32ยทStatus 
-    N32ยทshift_right(uint32_t shift_count, N32ยทT *spill, N32ยทT *operand, N32ยทT *fill){
-      return N32ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
-    }
-
-    Local N32ยทStatus 
-    N32ยทarithmetic_shift_right(uint32_t shift_count, N32ยทT *operand, N32ยทT *spill){
-
-      // Guard against excessive shift counts
-      if(shift_count > 31) return N32ยทStatusยทgt_max_shift_count;
-
-      // A NULL operand is treated as zero
-      if(operand == NULL){
-        operand = &N32ยทt[0];
-        N32ยทcopy(operand, N32ยทzero);
-      }
-
-      // Pick the fill value based on the sign bit
-      N32ยทT *fill = (operand->d0 & 0x80000000) ? N32ยทall_one_bit : N32ยทzero;
-
-      // Call shift_right with the appropriate fill
-      return N32ยทshift_right(shift_count, spill, operand, fill);
-    }
-
-    Local const N32ยทM N32ยทm = {
-
-      .allocate_array = N32ยทallocate_array
-      ,.allocate_array_zero = N32ยทallocate_array_zero
-      ,.deallocate = N32ยทdeallocate
-
-      ,.copy = N32ยทcopy
-      ,.bit_and = N32ยทbit_and
-      ,.bit_or = N32ยทbit_or
-      ,.bit_complement = N32ยทbit_complement
-      ,.bit_twos_complement = N32ยทbit_twos_complement
-      ,.compare = N32ยทcompare
-      ,.lt = N32ยทlt
-      ,.gt = N32ยทgt
-      ,.eq = N32ยทeq
-      ,.eq_zero = N32ยทeq_zero
-      ,.accumulate = N32ยทaccumulate
-      ,.add = N32ยทadd
-      ,.increment = N32ยทincrement
-      ,.subtract = N32ยทsubtract
-      ,.multiply = N32ยทmultiply
-      ,.divide = N32ยทdivide
-      ,.modulus = N32ยทmodulus
-      ,.shift_left = N32ยทshift_left
-      ,.shift_right = N32ยทshift_right
-      ,.arithmetic_shift_right = N32ยทarithmetic_shift_right
-
-      ,.access = N32ยทaccess
-      ,.from_uint32 = N32ยทfrom_uint32
-    };
-
-  #endif
-
-#endif
diff --git a/developer/cc๐Ÿ–‰/N64.lib.c b/developer/cc๐Ÿ–‰/N64.lib.c
deleted file mode 100644 (file)
index 6058e9b..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
-  N64 - a 64-bit native type
-
-  For binary operations: a op b -> c
-
-  Similar to N32, but now each Digit is 64 bits. Where a 128-bit
-  intermediate is necessary (e.g. multiplication), we handle it
-  manually using two 64-bit parts.
-
-  On the subject of multiple pointers indicating the same location in memory:
-
-  When a routine has multiple results, and one or more of the result location
-  pointers point to the same storage, the routine will either return an error
-  status, or have defined behavior.
-
-  When a routine has multiple operands, in any combination, those
-  pointers can point to the same location, and the routine will
-  function as advertised.
-
-  When an operand functions as both an input and a result, perhaps due
-  to a result pointer pointing to the same place as an operand
-  pointer, the routine will function as advertised. (Internally the
-  routine might make a temporary copy of the operand to accomplish
-  this.)
-*/
-
-#define N64ยทDEBUG
-
-#ifndef FACE
-#define N64ยทIMPLEMENTATION
-#define FACE
-#endif
-
-//--------------------------------------------------------------------------------
-// Interface
-
-#ifndef N64ยทFACE
-#define N64ยทFACE
-
-  #include <stdint.h>
-  #include <stdbool.h>
-  #include <stdarg.h>
-  #include <stdlib.h>
-
-  //----------------------------------------
-  // Instance Data (Declaration Only)
-
-  typedef uint64_t Extent;
-  typedef uint64_t Digit;
-
-  typedef struct N64ยทT N64ยทT;
-
-  extern N64ยทT *N64ยทzero;
-  extern N64ยทT *N64ยทone;
-  extern N64ยทT *N64ยทall_one_bit;
-  extern N64ยทT *N64ยทlsb;
-  extern N64ยทT *N64ยทmsb;
-
-  //----------------------------------------
-  // Return/Error Status and handlers
-
-  typedef enum {
-    N64ยทStatusยทok = 0
-   ,N64ยทStatusยทoverflow = 1
-   ,N64ยทStatusยทaccumulator1_overflow = 2
-   ,N64ยทStatusยทcarry = 3
-   ,N64ยทStatusยทborrow = 4
-   ,N64ยทStatusยทundefined_divide_by_zero = 5
-   ,N64ยทStatusยทundefined_modulus_zero = 6
-   ,N64ยทStatusยทgt_max_shift_count = 7
-   ,N64ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
-   ,N64ยทStatusยทone_word_product = 9
-   ,N64ยทStatusยทtwo_word_product = 10
-  } N64ยทStatus;
-
-  typedef enum {
-    N64ยทOrder_lt = -1
-   ,N64ยทOrder_eq = 0
-   ,N64ยทOrder_gt = 1
-  } N64ยทOrder;
-
-  typedef N64ยทT *(*N64ยทAllocate_MemoryFault)(Extent);
-
-  //----------------------------------------
-  // Interface
-
-  typedef struct {
-
-    N64ยทT *(*allocate_array_zero)(Extent, N64ยทAllocate_MemoryFault);
-    N64ยทT *(*allocate_array)(Extent, N64ยทAllocate_MemoryFault);
-    void   (*deallocate)(N64ยทT*);
-
-    void        (*copy)(N64ยทT*, N64ยทT*);
-    void        (*bit_and)(N64ยทT*, N64ยทT*, N64ยทT*);
-    void        (*bit_or)(N64ยทT*, N64ยทT*, N64ยทT*);
-    void        (*bit_complement)(N64ยทT*, N64ยทT*);
-    void        (*bit_twos_complement)(N64ยทT*, N64ยทT*);
-    N64ยทOrder   (*compare)(N64ยทT*, N64ยทT*);
-    bool        (*lt)(N64ยทT*, N64ยทT*);
-    bool        (*gt)(N64ยทT*, N64ยทT*);
-    bool        (*eq)(N64ยทT*, N64ยทT*);
-    bool        (*eq_zero)(N64ยทT*);
-    N64ยทStatus  (*accumulate)(N64ยทT *accumulator1, N64ยทT *accumulator0, ...);
-    N64ยทStatus  (*add)(N64ยทT*, N64ยทT*, N64ยทT*);
-    bool        (*increment)(N64ยทT *a);
-    N64ยทStatus  (*subtract)(N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*multiply)(N64ยทT*, N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*divide)(N64ยทT*, N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*modulus)(N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*shift_left)(Extent, N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*shift_right)(Extent, N64ยทT*, N64ยทT*, N64ยทT*);
-    N64ยทStatus  (*arithmetic_shift_right)(Extent, N64ยทT*, N64ยทT*);
-
-    N64ยทT*      (*access)(N64ยทT*, Extent);
-    void        (*from_uint64)(N64ยทT *destination, uint64_t value);
-
-  } N64ยทM;
-
-  Local const N64ยทM N64ยทm; // initialized in the LOCAL section
-
-#endif
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef N64ยทIMPLEMENTATION
-
-  // this part goes into the library
-  #ifndef LOCAL
-
-    #include <stdarg.h>
-    #include <stdlib.h>
-
-    struct N64ยทT {
-      Digit d0;
-    };
-
-    // For constants, we store them in an array for convenience
-    // 0, 1, all bits set (~0ULL), and MSB set (1ULL<<63)
-    N64ยทT N64ยทconstant[4] = {
-      {.d0 = 0ULL},
-      {.d0 = 1ULL},
-      {.d0 = ~(uint64_t)0ULL},
-      {.d0 = 1ULL << 63}
-    };
-
-    N64ยทT *N64ยทzero = &N64ยทconstant[0];
-    N64ยทT *N64ยทone = &N64ยทconstant[1];
-    N64ยทT *N64ยทall_one_bit = &N64ยทconstant[2];
-    N64ยทT *N64ยทmsb = &N64ยทconstant[3];
-    N64ยทT *N64ยทlsb = &N64ยทconstant[1];
-
-    // allocate an array of N64
-    N64ยทT *N64ยทallocate_array(Extent extent, N64ยทAllocate_MemoryFault memory_fault){
-      N64ยทT *instance = malloc( (extent + 1) * sizeof(N64ยทT) );
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    N64ยทT *N64ยทallocate_array_zero(Extent extent, N64ยทAllocate_MemoryFault memory_fault){
-      N64ยทT *instance = calloc(extent + 1, sizeof(N64ยทT));
-      if(!instance){
-        return memory_fault ? memory_fault(extent) : NULL;
-      }
-      return instance;
-    }
-
-    void N64ยทdeallocate(N64ยทT *unencumbered){
-      free(unencumbered);
-    }
-
-  #endif
-
-  // This part is included after the library user's code
-  #ifdef LOCAL
-
-    // instance
-
-    struct N64ยทT {
-      Digit d0;
-    };
-
-    // local temporary variables
-    Local N64ยทT N64ยทt[4];
-
-    // allocation references
-    extern N64ยทT *N64ยทallocate_array(Extent, N64ยทAllocate_MemoryFault);
-    extern N64ยทT *N64ยทallocate_array_zero(Extent, N64ยทAllocate_MemoryFault);
-    extern void   N64ยทdeallocate(N64ยทT *);
-
-    // Access array
-    Local N64ยทT* N64ยทaccess(N64ยทT *array, Extent index){
-      return &array[index];
-    }
-
-    Local void N64ยทfrom_uint64(N64ยทT *destination, uint64_t value){
-      if(destination == NULL) return;
-      destination->d0 = value;
-    }
-
-    // copy
-    Local void N64ยทcopy(N64ยทT *destination, N64ยทT *source){
-      if(source == destination) return;
-      *destination = *source;
-    }
-
-    // bit operations
-
-    Local void N64ยทbit_and(N64ยทT *result, N64ยทT *a, N64ยทT *b){
-      result->d0 = a->d0 & b->d0;
-    }
-
-    Local void N64ยทbit_or(N64ยทT *result, N64ยทT *a, N64ยทT *b){
-      result->d0 = a->d0 | b->d0;
-    }
-
-    Local void N64ยทbit_complement(N64ยทT *result, N64ยทT *a){
-      result->d0 = ~a->d0;
-    }
-
-    Local void N64ยทbit_twos_complement(N64ยทT *result, N64ยทT *a){
-      result->d0 = ~a->d0 + 1ULL;
-    }
-
-    // compare & test functions
-
-    Local N64ยทOrder N64ยทcompare(N64ยทT *a, N64ยทT *b){
-      if(a->d0 < b->d0) return N64ยทOrder_lt;
-      if(a->d0 > b->d0) return N64ยทOrder_gt;
-      return N64ยทOrder_eq;
-    }
-
-    Local bool N64ยทlt(N64ยทT *a, N64ยทT *b){
-      return (a->d0 < b->d0);
-    }
-
-    Local bool N64ยทgt(N64ยทT *a, N64ยทT *b){
-      return (a->d0 > b->d0);
-    }
-
-    Local bool N64ยทeq(N64ยทT *a, N64ยทT *b){
-      return (a->d0 == b->d0);
-    }
-
-    Local bool N64ยทeq_zero(N64ยทT *a){
-      return (a->d0 == 0ULL);
-    }
-
-    // arithmetic operations
-
-    // accumulate
-    Local N64ยทStatus N64ยทaccumulate(N64ยทT *accumulator1, N64ยทT *accumulator0, ...){
-      va_list args;
-      va_start(args, accumulator0);
-
-      uint64_t sum = accumulator0->d0;
-      uint64_t carry = 0;
-      N64ยทT *current;
-
-      while( (current = va_arg(args, N64ยทT*)) ){
-        uint64_t prior = sum;
-        sum += current->d0;
-        if(sum < prior){  // indicates carry
-          carry++;
-          // if carry overflowed a 64-bit, that's an accumulator1 overflow
-          if(carry == 0ULL){
-            va_end(args);
-            return N64ยทStatusยทaccumulator1_overflow;
-          }
-        }
-      }
-      va_end(args);
-
-      accumulator1->d0 = carry;
-      return N64ยทStatusยทok;
-    }
-
-    // add
-    Local N64ยทStatus N64ยทadd(N64ยทT *sum, N64ยทT *a, N64ยทT *b){
-      __uint128_t result = ( __uint128_t )a->d0 + ( __uint128_t )b->d0;
-      // But to avoid using a GNU extension, we can do the simpler approach:
-      // Actually let's do it directly with 64-bit since we only need to detect carry out of 64 bits:
-      uint64_t temp = a->d0 + b->d0;
-      sum->d0 = temp;
-      if(temp < a->d0) return N64ยทStatusยทcarry;  // means we overflowed
-      return N64ยทStatusยทok;
-    }
-
-    Local bool N64ยทincrement(N64ยทT *a){
-      uint64_t old = a->d0;
-      a->d0++;
-      // if it wrapped around to 0, then it was 0xFFFFFFFFFFFFFFFF
-      return (a->d0 < old);
-    }
-
-    // subtract
-    Local N64ยทStatus N64ยทsubtract(N64ยทT *difference, N64ยทT *a, N64ยทT *b){
-      uint64_t tmpA = a->d0;
-      uint64_t tmpB = b->d0;
-      uint64_t diff = tmpA - tmpB;
-      difference->d0 = diff;
-      if(diff > tmpA) return N64ยทStatusยทborrow; // indicates we borrowed
-      return N64ยทStatusยทok;
-    }
-
-    // multiply
-    // We'll do a 64x64->128 using two 64-bit accumulators
-    Local N64ยทStatus N64ยทmultiply(N64ยทT *product1, N64ยทT *product0, N64ยทT *a, N64ยทT *b){
-      uint64_t A = a->d0;
-      uint64_t B = b->d0;
-
-      // Break each operand into high & low 32 bits
-      uint64_t a_lo = (uint32_t)(A & 0xffffffffULL);
-      uint64_t a_hi = A >> 32;
-      uint64_t b_lo = (uint32_t)(B & 0xffffffffULL);
-      uint64_t b_hi = B >> 32;
-
-      // partial products
-      uint64_t low = a_lo * b_lo;                   // 64-bit
-      uint64_t cross = (a_lo * b_hi) + (a_hi * b_lo); // potentially up to 2 * 32 bits => 64 bits
-      uint64_t high = a_hi * b_hi;                  // up to 64 bits
-
-      // incorporate cross into low, high
-      // cross is effectively the middle bits, so shift cross by 32 and add to low
-      uint64_t cross_low = (cross & 0xffffffffULL) << 32;  // lower part
-      uint64_t cross_high = cross >> 32;                   // upper part
-
-      // add cross_low to low, capture carry
-      uint64_t old_low = low;
-      low += cross_low;
-      if(low < old_low) cross_high++;
-
-      // final high
-      high += cross_high;
-
-      // store results
-      product0->d0 = low;
-      product1->d0 = high;
-
-      if(high == 0ULL) return N64ยทStatusยทone_word_product;
-      return N64ยทStatusยทtwo_word_product;
-    }
-
-    // divide
-    Local N64ยทStatus N64ยทdivide(N64ยทT *remainder, N64ยทT *quotient, N64ยทT *a, N64ยทT *b){
-      // we do not handle a > 64-bit, just the single 64-bit
-      if(b->d0 == 0ULL) return N64ยทStatusยทundefined_divide_by_zero;
-
-      uint64_t divd = a->d0; // dividend
-      uint64_t divs = b->d0; // divisor
-
-      quotient->d0 = divd / divs;
-      remainder->d0 = divd - (quotient->d0 * divs);
-
-      return N64ยทStatusยทok;
-    }
-
-    // modulus
-    Local N64ยทStatus N64ยทmodulus(N64ยทT *remainder, N64ยทT *a, N64ยทT *b){
-      if(b->d0 == 0ULL) return N64ยทStatusยทundefined_modulus_zero;
-
-      uint64_t divd = a->d0;
-      uint64_t divs = b->d0;
-      uint64_t q = divd / divs;
-      remainder->d0 = divd - (q * divs);
-
-      return N64ยทStatusยทok;
-    }
-
-    // bit motion
-
-    typedef uint64_t (*ShiftOp)(uint64_t, uint64_t);
-
-    Local uint64_t shift_left_op(uint64_t value, uint64_t amount){
-      return (value << amount);
-    }
-
-    Local uint64_t shift_right_op(uint64_t value, uint64_t amount){
-      return (value >> amount);
-    }
-
-    // modifies all three of its operands
-    // in the case of duplicate operands this is the order: first modifies operand, then fill, then spill
-    Local N64ยทStatus N64ยทshift
-    (
-     uint64_t shift_count,
-     N64ยทT *spill,
-     N64ยทT *operand,
-     N64ยทT *fill,
-     ShiftOp shift_op,
-     ShiftOp complement_shift_op
-    ){
-      if(operand == NULL && spill == NULL) return N64ยทStatusยทok;
-
-      // Treat NULL operand as zero
-      if(operand == NULL){
-        operand = &N64ยทt[0];
-        N64ยทcopy(operand, N64ยทzero);
-      }
-
-      // Shifting more than 63 bits breaks fill/spill logic
-      if(shift_count > 63ULL) return N64ยทStatusยทgt_max_shift_count;
-
-      N64ยทT *given_operand = &N64ยทt[1];
-      N64ยทcopy(given_operand, operand);
-
-      // Perform the shift
-      operand->d0 = shift_op(given_operand->d0, shift_count);
-      if(fill != NULL){
-        fill->d0 = complement_shift_op(fill->d0, (64ULL - shift_count));
-        N64ยทbit_or(operand, operand, fill);
-      }
-      if(spill != NULL){
-        spill->d0 = shift_op(spill->d0, shift_count);
-        spill->d0 += complement_shift_op(given_operand->d0, (64ULL - shift_count));
-      }
-
-      return N64ยทStatusยทok;
-    }
-
-    Local N64ยทStatus N64ยทshift_left(uint64_t shift_count, N64ยทT *spill, N64ยทT *operand, N64ยทT *fill){
-      return N64ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
-    }
-
-    Local N64ยทStatus N64ยทshift_right(uint64_t shift_count, N64ยทT *spill, N64ยทT *operand, N64ยทT *fill){
-      return N64ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
-    }
-
-    Local N64ยทStatus N64ยทarithmetic_shift_right(uint64_t shift_count, N64ยทT *operand, N64ยทT *spill){
-      if(shift_count > 63ULL) return N64ยทStatusยทgt_max_shift_count;
-
-      // A NULL operand is treated as zero
-      if(operand == NULL){
-        operand = &N64ยทt[0];
-        N64ยทcopy(operand, N64ยทzero);
-      }
-
-      // sign bit check
-      N64ยทT *fill = (operand->d0 & (1ULL << 63)) ? N64ยทall_one_bit : N64ยทzero;
-      return N64ยทshift_right(shift_count, spill, operand, fill);
-    }
-
-    Local const N64ยทM N64ยทm = {
-      .allocate_array = N64ยทallocate_array
-     ,.allocate_array_zero = N64ยทallocate_array_zero
-     ,.deallocate = N64ยทdeallocate
-
-     ,.copy = N64ยทcopy
-     ,.bit_and = N64ยทbit_and
-     ,.bit_or = N64ยทbit_or
-     ,.bit_complement = N64ยทbit_complement
-     ,.bit_twos_complement = N64ยทbit_twos_complement
-     ,.compare = N64ยทcompare
-     ,.lt = N64ยทlt
-     ,.gt = N64ยทgt
-     ,.eq = N64ยทeq
-     ,.eq_zero = N64ยทeq_zero
-     ,.accumulate = N64ยทaccumulate
-     ,.add = N64ยทadd
-     ,.increment = N64ยทincrement
-     ,.subtract = N64ยทsubtract
-     ,.multiply = N64ยทmultiply
-     ,.divide = N64ยทdivide
-     ,.modulus = N64ยทmodulus
-     ,.shift_left = N64ยทshift_left
-     ,.shift_right = N64ยทshift_right
-     ,.arithmetic_shift_right = N64ยทarithmetic_shift_right
-
-     ,.access = N64ยทaccess
-     ,.from_uint64 = N64ยทfrom_uint64
-    };
-
-  #endif
-
-#endif
diff --git a/developer/cc๐Ÿ–‰/N8.lib.c b/developer/cc๐Ÿ–‰/N8.lib.c
deleted file mode 100644 (file)
index df6e01c..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
-  N8 - PN = refers to the use of processor native accumulator 
-
-  For binary operations:  a op b -> c
-
-  See the document on the proper use of the Natural types.
-
-  On the subject of multiple pointers indicating the same location in memory:
-
-  When a routine has multiple results, and one or more of the result location
-  pointers point to the same storage, the routine will either return an error
-  status, or have defined behavior.
-
-  When a routine has multiple operands, in any combination, those
-  pointers can point to the same location, and the routine will
-  function as advertised.
-
-  When an operand functions as both an input and a result, perhaps due
-  to a result pointer pointing to the same place as an operand
-  pointer, the routine will function as advertised. (Internally the
-  routine might make a temporary copy of the operand to accomplish
-  this.)
-*/
-
-#define N8ยทDEBUG
-
-#ifndef FACE
-#define N8ยทIMPLEMENTATION
-#define FACE
-#endif
-
-//--------------------------------------------------------------------------------
-// Interface
-
-#ifndef N8ยทFACE
-#define N8ยทFACE
-
-  #include <stdint.h>
-  #include <stdbool.h>
-  #include <stdarg.h>
-  #include <stdlib.h>
-
-  //----------------------------------------
-  // Instance Data (Declaration Only)
-
-  typedef uint8_t Extent;
-  typedef uint8_t Digit;
-
-  typedef struct N8ยทT N8ยทT;
-
-  extern N8ยทT *N8ยทzero;
-  extern N8ยทT *N8ยทone;
-  extern N8ยทT *N8ยทall_one_bit;
-  extern N8ยทT *N8ยทlsb;
-  extern N8ยทT *N8ยทmsb;
-
-  //----------------------------------------
-  // Return/Error Status and handlers
-
-  typedef enum{
-    N8ยทStatusยทok = 0
-   ,N8ยทStatusยทoverflow = 1
-   ,N8ยทStatusยทaccumulator1_overflow = 2
-   ,N8ยทStatusยทcarry = 3
-   ,N8ยทStatusยทborrow = 4
-   ,N8ยทStatusยทundefined_divide_by_zero = 5
-   ,N8ยทStatusยทundefined_modulus_zero = 6
-   ,N8ยทStatusยทgt_max_shift_count = 7
-   ,N8ยทStatusยทspill_eq_operand = 8
-   ,N8ยทStatusยทone_word_product = 9
-   ,N8ยทStatusยทtwo_word_product = 10
-  } N8ยทStatus;
-
-  typedef enum{
-    N8ยทOrder_lt = -1
-   ,N8ยทOrder_eq = 0
-   ,N8ยทOrder_gt = 1
-  } N8ยทOrder;
-
-  typedef N8ยทT *( *N8ยทAllocate_MemoryFault )(Extent);
-
-  //----------------------------------------
-  // Interface
-
-  typedef struct{
-
-    N8ยทT *(*allocate_array_zero)(Extent, N8ยทAllocate_MemoryFault);
-    N8ยทT *(*allocate_array)(Extent, N8ยทAllocate_MemoryFault);
-    void (*deallocate)(N8ยทT*);
-
-    void (*copy)(N8ยทT*, N8ยทT*);
-    void (*bit_and)(N8ยทT*, N8ยทT*, N8ยทT*);
-    void (*bit_or)(N8ยทT*, N8ยทT*, N8ยทT*);
-    void (*bit_complement)(N8ยทT*, N8ยทT*);
-    void (*bit_twos_complement)(N8ยทT*, N8ยทT*);
-    N8ยทOrder (*compare)(N8ยทT*, N8ยทT*);
-    bool (*lt)(N8ยทT*, N8ยทT*);
-    bool (*gt)(N8ยทT*, N8ยทT*);
-    bool (*eq)(N8ยทT*, N8ยทT*);
-    bool (*eq_zero)(N8ยทT*);
-    N8ยทStatus (*accumulate)(N8ยทT *accumulator1 ,N8ยทT *accumulator0 ,...);
-    N8ยทStatus (*add)(N8ยทT*, N8ยทT*, N8ยทT*);
-    bool (*increment)(N8ยทT *a);
-    N8ยทStatus (*subtract)(N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*multiply)(N8ยทT*, N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*divide)(N8ยทT*, N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*modulus)(N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*shift_left)(Extent, N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*shift_right)(Extent, N8ยทT*, N8ยทT*, N8ยทT*);
-    N8ยทStatus (*arithmetic_shift_right)(Extent, N8ยทT*, N8ยทT*);
-
-    N8ยทT* (*access)(N8ยทT*, Extent);
-    void (*from_uint32)(N8ยทT *destination ,uint32_t value);
-  } N8ยทM;
-
-  Local const N8ยทM N8ยทm; // initialized in the LOCAL section
-
-#endif
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef N8ยทIMPLEMENTATION
-
-  // this part goes into the library
-  #ifndef LOCAL
-
-  #include <stdarg.h>
-  #include <stdlib.h>
-
-  struct N8ยทT{
-    Digit d0;
-  };
-
-  N8ยทT N8ยทconstant[4] = {
-  {.d0 = 0},
-  {.d0 = 1},
-  {.d0 = ~(uint8_t)0},
-  {.d0 = 1 << 7}
-  };
-
-  N8ยทT *N8ยทzero = &N8ยทconstant[0];
-  N8ยทT *N8ยทone = &N8ยทconstant[1];
-  N8ยทT *N8ยทall_one_bit = &N8ยทconstant[2];
-  N8ยทT *N8ยทmsb = &N8ยทconstant[3];
-  N8ยทT *N8ยทlsb = &N8ยทconstant[1];
-
-  // the allocate an array of N8
-  N8ยทT *N8ยทallocate_array(Extent extent ,N8ยทAllocate_MemoryFault memory_fault){
-    N8ยทT *instance = malloc((extent + 1) * sizeof(N8ยทT));
-    if(!instance){
-      return memory_fault ? memory_fault(extent) : NULL;
-    }
-    return instance;
-  }
-
-  N8ยทT *N8ยทallocate_array_zero(Extent extent ,N8ยทAllocate_MemoryFault memory_fault){
-    N8ยทT *instance = calloc(extent + 1, sizeof(N8ยทT));
-    if(!instance){
-      return memory_fault ? memory_fault(extent) : NULL;
-    }
-    return instance;
-  }
-
-  void N8ยทdeallocate(N8ยทT *unencumbered){
-    free(unencumbered);
-  }
-
-
-  #endif
-
-  // This part is included after the library user's code
-  #ifdef LOCAL
-
-    // instance
-
-    struct N8ยทT{
-      Digit d0;
-    };
-
-    // temporary variables
-    Local N8ยทT N8ยทt[4];
-
-    // allocation 
-
-    extern N8ยทT *N8ยทallocate_array(Extent, N8ยทAllocate_MemoryFault);
-    extern N8ยทT *N8ยทallocate_array_zero(Extent, N8ยทAllocate_MemoryFault);
-    extern void N8ยทdeallocate(N8ยทT *);
-
-    // so the user can access numbers in an array allocation
-    Local N8ยทT* N8ยทaccess(N8ยทT *array ,Extent index){
-      return &array[index];
-    }
-
-    Local void N8ยทfrom_uint32(N8ยทT *destination ,uint32_t value){
-      if(destination == NULL) return;
-      destination->d0 = (uint8_t)(value & 0xFF);
-    }
-
-    // copy, convenience copy
-
-    Local void N8ยทcopy(N8ยทT *destination ,N8ยทT *source){
-      if(source == destination) return;
-      *destination = *source;
-    }
-
-    Local void N8ยทset_to_zero(N8ยทT *instance){
-      instance->d0 = 0;
-    }
-
-    Local void N8ยทset_to_one(N8ยทT *instance){
-      instance->d0 = 1;
-    }
-
-    // bit operations
-
-    Local void N8ยทbit_and(N8ยทT *result, N8ยทT *a, N8ยทT *b){
-      result->d0 = a->d0 & b->d0;
-    }
-
-    Local void N8ยทbit_or(N8ยทT *result, N8ยทT *a, N8ยทT *b){
-      result->d0 = a->d0 | b->d0;
-    }
-
-    Local void N8ยทbit_complement(N8ยทT *result, N8ยทT *a){
-      result->d0 = ~a->d0;
-    }
-
-    Local void N8ยทbit_twos_complement(N8ยทT *result ,N8ยทT *a){
-      result->d0 = (uint8_t)(~a->d0 + 1);
-    }
-
-    // test functions
-
-    Local N8ยทOrder N8ยทcompare(N8ยทT *a, N8ยทT *b){
-      if(a->d0 < b->d0) return N8ยทOrder_lt;
-      if(a->d0 > b->d0) return N8ยทOrder_gt;
-      return N8ยทOrder_eq;
-    }
-
-    Local bool N8ยทlt(N8ยทT *a ,N8ยทT *b){
-      return a->d0 < b->d0;
-    }    
-
-    Local bool N8ยทgt(N8ยทT *a ,N8ยทT *b){
-      return a->d0 > b->d0;
-    }    
-
-    Local bool N8ยทeq(N8ยทT *a ,N8ยทT *b){
-      return a->d0 == b->d0;
-    }    
-
-    Local bool N8ยทeq_zero(N8ยทT *a){
-      return a->d0 == 0;
-    }    
-
-    // arithmetic operations
-
-    Local N8ยทStatus N8ยทaccumulate(N8ยทT *accumulator1 ,N8ยทT *accumulator0 ,...){
-
-      va_list args;
-      va_start(args ,accumulator0);
-      uint32_t sum = accumulator0->d0;
-      uint32_t carry = 0;
-      N8ยทT *current;
-
-      while( (current = va_arg(args ,N8ยทT*)) ){
-        sum += current->d0;
-        if(sum < current->d0){
-          (carry)++;
-          if(carry == 0){
-            va_end(args);
-            return N8ยทStatusยทaccumulator1_overflow;
-          }
-        }
-      }
-      va_end(args);
-
-      accumulator1->d0 = (uint8_t)carry;
-      return N8ยทStatusยทok;
-    }
-
-    Local N8ยทStatus N8ยทadd(N8ยทT *sum ,N8ยทT *a ,N8ยทT *b){
-      uint32_t result = (uint32_t)a->d0 + (uint32_t)b->d0;
-      sum->d0 = (uint8_t)(result & 0xFF);
-      return (result >> 8) ? N8ยทStatusยทcarry : N8ยทStatusยทok;
-    }
-
-    Local bool N8ยทincrement(N8ยทT *a){
-      a->d0++;
-      return (a->d0 == 0);
-    }
-
-    Local N8ยทStatus N8ยทsubtract(N8ยทT *difference ,N8ยทT *a ,N8ยทT *b){
-      uint32_t diff = (uint32_t)a->d0 - (uint32_t)b->d0;
-      difference->d0 = (uint8_t)(diff & 0xFF);
-      return (diff > a->d0) ? N8ยทStatusยทborrow : N8ยทStatusยทok;
-    }
-
-    Local N8ยทStatus N8ยทmultiply(N8ยทT *product1 ,N8ยทT *product0 ,N8ยทT *a ,N8ยทT *b){
-      uint32_t product = (uint32_t)a->d0 * (uint32_t)b->d0;
-      product0->d0 = (uint8_t)(product & 0xFF);
-      product1->d0 = (uint8_t)((product >> 8) & 0xFF);
-
-      if(product1->d0 == 0) return N8ยทStatusยทone_word_product;
-      return N8ยทStatusยทtwo_word_product;
-    }
-
-    Local N8ยทStatus N8ยทdivide(N8ยทT *remainder ,N8ยทT *quotient ,N8ยทT *a ,N8ยทT *b){
-      if(b->d0 == 0) return N8ยทStatusยทundefined_divide_by_zero;
-
-      uint32_t dividend = a->d0;
-      uint32_t divisor = b->d0;
-      quotient->d0 = (uint8_t)(dividend / divisor);
-      remainder->d0 = (uint8_t)(dividend - (quotient->d0 * divisor));
-
-      return N8ยทStatusยทok;
-    }
-
-    Local N8ยทStatus N8ยทmodulus(N8ยทT *remainder ,N8ยทT *a ,N8ยทT *b){
-      if(b->d0 == 0) return N8ยทStatusยทundefined_modulus_zero;
-      uint32_t dividend = a->d0;
-      uint32_t divisor = b->d0;
-      uint32_t q = dividend / divisor;
-      remainder->d0 = (uint8_t)(dividend - (q * divisor));
-      return N8ยทStatusยทok;
-    }
-
-    // bit motion
-
-    typedef uint8_t (*ShiftOp)(uint8_t, uint8_t);
-
-    Local uint8_t shift_left_op(uint8_t value, uint8_t amount){
-      return (uint8_t)(value << amount);
-    }
-
-    Local uint8_t shift_right_op(uint8_t value, uint8_t amount){
-      return (uint8_t)(value >> amount);
-    }
-
-    Local N8ยทStatus N8ยทshift
-    (
-     uint8_t shift_count
-     ,N8ยทT *spill
-     ,N8ยทT *operand
-     ,N8ยทT *fill
-     ,ShiftOp shift_op
-     ,ShiftOp complement_shift_op
-    ){
-
-      if(operand == NULL && spill == NULL) return N8ยทStatusยทok;
-
-      if(operand == NULL){
-        operand = &N8ยทt[0];
-        N8ยทcopy(operand, N8ยทzero);
-      }
-
-      if(shift_count > 7) return N8ยทStatusยทgt_max_shift_count;
-
-      N8ยทT *given_operand = &N8ยทt[1];
-      N8ยทcopy(given_operand, operand);
-
-      operand->d0 = shift_op(given_operand->d0, shift_count);
-      if(fill != NULL){
-        fill->d0 = complement_shift_op(fill->d0, (8 - shift_count));
-        N8ยทbit_or(operand, operand, fill);
-      }
-      if(spill != NULL){
-        spill->d0 = shift_op(spill->d0, shift_count);
-        spill->d0 += complement_shift_op(given_operand->d0, (8 - shift_count));
-      }
-
-      return N8ยทStatusยทok;
-    }
-
-    Local N8ยทStatus 
-    N8ยทshift_left(uint8_t shift_count, N8ยทT *spill, N8ยทT *operand, N8ยทT *fill){
-      return N8ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
-    }
-
-    Local N8ยทStatus 
-    N8ยทshift_right(uint8_t shift_count, N8ยทT *spill, N8ยทT *operand, N8ยทT *fill){
-      return N8ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
-    }
-
-    Local N8ยทStatus 
-    N8ยทarithmetic_shift_right(uint8_t shift_count, N8ยทT *operand, N8ยทT *spill){
-
-      if(shift_count > 7) return N8ยทStatusยทgt_max_shift_count;
-
-      if(operand == NULL){
-        operand = &N8ยทt[0];
-        N8ยทcopy(operand, N8ยทzero);
-      }
-
-      N8ยทT *fill = (operand->d0 & 0x80) ? N8ยทall_one_bit : N8ยทzero;
-      return N8ยทshift_right(shift_count, spill, operand, fill);
-    }
-
-    Local const N8ยทM N8ยทm = {
-
-      .allocate_array = N8ยทallocate_array
-     ,.allocate_array_zero = N8ยทallocate_array_zero
-     ,.deallocate = N8ยทdeallocate
-
-     ,.copy = N8ยทcopy
-     ,.bit_and = N8ยทbit_and
-     ,.bit_or = N8ยทbit_or
-     ,.bit_complement = N8ยทbit_complement
-     ,.bit_twos_complement = N8ยทbit_twos_complement
-     ,.compare = N8ยทcompare
-     ,.lt = N8ยทlt
-     ,.gt = N8ยทgt
-     ,.eq = N8ยทeq
-     ,.eq_zero = N8ยทeq_zero
-     ,.accumulate = N8ยทaccumulate
-     ,.add = N8ยทadd
-     ,.increment = N8ยทincrement
-     ,.subtract = N8ยทsubtract
-     ,.multiply = N8ยทmultiply
-     ,.divide = N8ยทdivide
-     ,.modulus = N8ยทmodulus
-     ,.shift_left = N8ยทshift_left
-     ,.shift_right = N8ยทshift_right
-     ,.arithmetic_shift_right = N8ยทarithmetic_shift_right
-
-     ,.access = N8ยทaccess
-     ,.from_uint32 = N8ยทfrom_uint32
-    };
-
-  #endif
-
-#endif
index 3c49c35..75d54af 100644 (file)
@@ -1,14 +1,11 @@
 /*
-  TM - Tape Machine
+  TM - Tape Machine Model
 
-  `TMยทCVT` Cell Value Type`.
+   Template parameters
 
-*/
+    `TMยทCVT` Cell Value Type`.
 
-#ifndef FACE
-#define TMยทIMPLEMENTATION
-#define FACE
-#endif 
+*/
 
 //--------------------------------------------------------------------------------
 // Interface 
@@ -22,7 +19,7 @@
   #include "cpp_ext.c"
 
   #include "Core.lib.c"
-  #include "FG.lib.c"
+  #include "Binding.lib.c"
 
   #define TMยทDEBUG
   #ifdef TMยทDEBUG
     | TMยทHeadยทStatusยทrightmost
     ;
 
-  // set type equality pattern
-  #define EQ__TM__oo__TM
-
 #endif
 
 // once per TMยทCVT value
+#ifdef TMยทCVT
 #if ! FIND_ITEM( TMยทCVT ,TMยทTYPE_LIST )
 #define TMยทTYPE_LIST APPEND(TMยทTYPE_LIST ,TMยทTYPE)
 
-  // TMยท<TMยทCVT>ยทTableau
-  typedef struct ฮž(TM ,Tableau);
+  // declare 'TM' as a type
+  #define EQ__TM__oo__TM
+  #define BindingยทType TM 
+  #include "Binding.lib.c"
   
-  // bind the tableau to an FG table, call the binding a 'TM' type
-  #define FGยทType TM 
-  #include "FG.lib.c"
-
-  // extent is an index, hence its effect is a function of TMยทCVT
+  // `extent_t` is an index, so element size matters, so TMยทCVT matters
   typedef ฮž(extent_t ,TMยทCVT) size_t;
                            
   typedef struct{
@@ -95,7 +88,7 @@
     void (*step_left) (TM tm);
     void (*rewind)    (TM tm);
 
-    TMยทFG TMยทfg; // points to TMยทFG instance
+    TMยทBinding TMยทfg; // points to TMยทBinding instance
     ฮž(extent_t ,TMยทCVT) (*extent)(TM tm);
     TMยทCVT  (*read) (TM tm);
     void (*write)(TM tm ,TMยทCVT *remote_pt);
   );
 
 #endif 
+#endif 
 
 //--------------------------------------------------------------------------------
 // Implementation
 
-#ifdef TMยทIMPLEMENTATION
+#ifdef IMPLEMENTATION
 
   // implementation to go into the lib.a file
   //
   #ifdef LOCAL
 
     //----------------------------------------
-    // Dispatch wrapper
+    // included first without defining TMยทCVT
     //----------------------------------------
 
     #ifndef TMยทCVT
       //----------------------------------------
       // Initialization for TMยทfg
 
-      Local TMยทFG TMยทfg = {
+      Local TMยทBinding TMยทfg = {
         .Tapeยทtopo = TMยทTapeยทtopo
         ,.Tapeยทbounded = TMยทTapeยทbounded
         ,.Headยทstatus = TMยทHeadยทstatus
         return tm->fg.write(tm ,write_pt);
       }
 
-      Local ฮž(TM ,TMยทCVT)ยทFG ฮž(TM ,TMยทCVT)ยทfg = {
+      Local ฮž(TM ,TMยทCVT)ยทBinding ฮž(TM ,TMยทCVT)ยทfg = {
         .parent = TMยทfg
         ,.extent = ฮž(TM ,TMยทCVT)ยทextent
         ,.read = ฮž(TM ,TMยทCVT)ยทread
       //----------------------------------------
       // Initialization for ฮž(TMยทArray ,TMยทCVT)ยทfg
 
-      Local ฮž(TMยทArray ,TMยทCVT)ยทFG ฮž(TMยทArray ,TMยทCVT)ยทfg = {
+      Local ฮž(TMยทArray ,TMยทCVT)ยทBinding ฮž(TMยทArray ,TMยทCVT)ยทfg = {
         .tape = {
            .Tapeยทtopo   = ฮž(TMยทArray ,TMยทCVT)ยทTapeยทtopo
            .extent = ฮž(TMยทArray ,TMยทCVT)ยทextent
diff --git a/developer/cc๐Ÿ–‰/TM_scratch.c b/developer/cc๐Ÿ–‰/TM_scratch.c
deleted file mode 100644 (file)
index 13b2240..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-      // This initializes 'inner'.
-      // `alignment` is an extent, e.g. extent_ofยทAU(uint64_t) = 0x7
-      Local TMยทStatus ฮž(TMยทNX ,CVT)ยทlargest_aligned(
-        TMยทNXยทAU *outer ,ฮž(TMยทNX ,CVT) *inner ,extentยทAU alignment
-      ){
-        uintptr_t p0 = (uintptr_t)outer->position;
-        uintptr_t p1 = (uintptr_t)outer->position + outer->extent;
-
-        CVT *p0_aligned = (CVT *)(
-          (p0 + alignment) & ~( (uintptr_t)alignment )
-        );
-        CVT *p1_aligned = (CVT *)(
-          ( p1 - extent_ofยทAU(CVT) ) & ~( (uintptr_t)alignment )
-        );
-
-        if( p1_aligned < p0_aligned ) return TMยทStatusยทderailed;
-
-        inner->position = p0_aligned;
-        inner->extent = (ฮž(extent_t ,CVT))(p1_aligned - p0_aligned};
-        return TMยทStatusยทon_track;
-      }
-
-
-
-    
-      Local TMยทStatus TMยทNXยทtopo(TMยทNX *tm ,TMยทTapeยทTopo *topo){
-        #ifdef TMยทDebug
-          TMยทGuardยทinit_count(chk);
-          TMยทGuardยทfg.check(&chk ,1 ,tm ,TMยทNX_##CVTยทMsgยทtm);
-          TMยทGuardยทfg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
-          TMยทGuardยทif_return(chk);
-        #endif
-        if(tm->extentยทAU == 0){
-          *topo = TMยทTapeยทTopoยทsingleton; 
-        }else{
-          *topo = TMยทTapeยทTopoยทsegment;
-        }
-        return TMยทStatusยทon_track;
-      }
-
-      // extentยทAU is an AU index
-      Local TMยทStatus TMยทNXยทextentยทAU(TMยทNX *tm ,extentยทAU *extentยทAU){
-        TMยทTapeยทTopo topo;
-        TMยทStatus status = TMยทNX_##CVTยทtopo(tm ,&topo);
-        boolean good_topo = 
-          (status == TMยทStatusยทon_track) && (topo & TMยทTapeยทTopoยทfinite_nz)
-          ;
-
-        #ifdef TMยทDebug
-          TMยทGuardยทinit_count(chk);
-          TMยทGuardยทfg.check(&chk ,1 ,tm ,TMยทNXยทMsgยทtm);
-          TMยทGuardยทfg.check(&chk ,1 ,extentยทAU ,TMยทNXยทMsgยทextentยทAU);
-          TMยทGuardยทfg.check(
-            &chk ,0 ,good_topo
-            ,"Tape does not exist or topology does not have an extentยทAU."
-          );
-          TMยทGuardยทif_return(chk);
-        #endif
-
-        if(!good_topo) return TMยทStatusยทderailed;
-        *extentยทAU = tm->array.extentยทAU;
-        return TMยทStatusยทon_track;
-      }
-
-    #endif
index 573c27c..dd89cd9 100644 (file)
@@ -65,9 +65,15 @@ DEBUG
 
 #include <stdio.h>
 #define DEBUG_CPP
+
+// print the macro and the evaluation of the macro at compile time:
+//   #pragma message( STR_VAL(<macro>) )
+
 #define STR(...) #__VA_ARGS__
+#define VAL(...) STR(__VA_ARGS__)
+#define STR_VAL(...) #__VA_ARGS__ " -> " VAL(__VA_ARGS__)
 
-// print the macro and the evaluation of the macro
+// print the macro and the evaluation of the macro at run time:
 #define SHOW(expr) printf("%s -> %s\n", #expr, STR(expr))
 
 /*===========================================================================
index bc241d7..a188507 100644 (file)
@@ -62,8 +62,8 @@ DROPE_NOT_EXISTS_RIGHT
     ( NOT_EXISTS(__VA_ARGS__) ) \
     () \
     (IF \
-      ( predicate(FIRST(__VA_ARGS__)) ) \
-      ( FIRST( ,__VA_ARGS__) )                    \
+      ( predicate(FIRST(,__VA_ARGS__)) )         \
+      ( FIRST(,__VA_ARGS__) )                    \
       ( DEFER3(_FIND_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
      )
 #define _FIND_CONFEDERATE() _FIND
@@ -76,9 +76,9 @@ DROPE_NOT_EXISTS_RIGHT
     ( NOT_EXISTS(__VA_ARGS__) ) \
     () \
     (IF \
-      ( EQ(item ,FIRST(__VA_ARGS__)) )             \
-      ( FIRST( ,__VA_ARGS__) )                    \
-      ( DEFER3(_FIND_ITEM_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
+      ( EQ(item ,FIRST(,__VA_ARGS__)) )          \
+      ( item )                    \
+      ( DEFER3(_FIND_ITEM_CONFEDERATE) ()(item ,REST(__VA_ARGS__)) )     \
      )
 #define _FIND_ITEM_CONFEDERATE() _FIND_ITEM
 
diff --git a/developer/cc๐Ÿ–‰/environment.h b/developer/cc๐Ÿ–‰/environment.h
deleted file mode 100644 (file)
index cdea83c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef MpblockยทENVIRONMENT_H
-#define MpblockยทENVIRONMENT_H
-
-
-#endif
diff --git a/developer/cc๐Ÿ–‰/test_setup.cli.c b/developer/cc๐Ÿ–‰/test_setup.cli.c
deleted file mode 100644 (file)
index f1c6e68..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-
-  A placeholder to see if make etc. is working.
-
-*/
-
-#define IFACE
-#include <stdio.h>
-#include <stdlib.h>
-
-// No need to define IMPLEMENTATION as `main` is one and done.
-
-int main(int argc ,char *argv[] ,char *envp[]){
-  if(argc != 1){
-    fprintf(stderr, "Usage: %s\n", argv[0]);
-    return EXIT_FAILURE;
-  }
-
-  fprintf(stderr, "%s done\n", argv[0]);
-
-  return 0;
-}
diff --git a/developer/cc๐Ÿ–‰/update.lib.c b/developer/cc๐Ÿ–‰/update.lib.c
deleted file mode 100644 (file)
index 61c5cf4..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-  Copy - Memory copy operations with attention to alignment.
-  Provides optimized copy and byte order reversal functions.
-*/
-
-#define CopyยทDEBUG
-
-#ifndef FACE
-#define CopyยทIMPLEMENTATION
-#define FACE
-#endif 
-
-//--------------------------------------------------------------------------------
-// Interface
-
-#ifndef CopyยทFACE
-#define CopyยทFACE
-
-  #include <stdint.h>
-  #include <stddef.h>
-
-  typedef struct{
-    void *read0 
-    ,size_t read_size
-    ,void *write0
-    ,size_t write_size;
-  } Copyยทit;
-
-  typedef enum{
-     CopyยทStatusยทperfect_fit = 0
-    ,CopyยทStatusยทargument_guard
-    ,CopyยทStatusยทread_surplus
-    ,CopyยทStatusยทread_surplus_write_gap
-    ,CopyยทStatusยทwrite_available
-    ,CopyยทStatusยทwrite_gap;
-  } CopyยทStatus;
-
-  typedef enum{
-    CopyยทWFItยทModeยทnone = 0
-    ,CopyยทWFItยทModeยทbytes
-    ,CopyยทWFItยทModeยทbytes_reverse
-    ,CopyยทWFItยทModeยทwrite_hex
-    ,CopyยทWFItยทModeยทread_hex;
-  } CopyยทWFItยทMode;
-
-  typedef enum{
-    CopyยทWFItยทStatusยทvalid = 0
-    ,CopyยทWFItยทStatusยทnull_read
-    ,CopyยทWFItยทStatusยทnull_write
-    ,CopyยทWFItยทStatusยทzero_buffer
-    ,CopyยทWFItยทStatusยทoverlap
-    ,CopyยทWFItยทStatusยทwrite_too_small;
-  } CopyยทWFItยทStatus;
-
-  typedef struct{
-    void *region( void *read0 ,void *read1 ,void *write0 )
-    ,void *reverse_byte_order( void *read0 ,void *read1 ,void *write0 );
-  } CopyยทM;
-
-#endif
-
-//--------------------------------------------------------------------------------
-// Implementation
-
-#ifdef CopyยทIMPLEMENTATION
-
-  // this part goes into Nlib.a
-  #ifndef LOCAL
-  #endif 
-
-  #ifdef LOCAL
-
-    Local CopyยทWFItยทStatus Copyยทwellformed_it(Copyยทit *it){
-      char *this_name = "Copyยทwellformed_it";
-      CopyยทWFItยทStatus status = CopyยทWFItยทStatusยทvalid;
-
-      if(it->read0 == NULL){
-        fprintf( stderr ,"%s: NULL read pointer\n" ,this_name );
-        status |= CopyยทWFItยทStatusยทnull_read;
-      }
-
-      if(it->write0 == NULL){
-        fprintf( stderr ,"%s: NULL write pointer\n" ,this_name );
-        status |= CopyยทWFItยทStatusยทnull_write;
-      }
-
-      if(it->read_size == 0){
-        fprintf( stderr ,"%s: Zero-sized read buffer\n" ,this_name );
-        status |= CopyยทWFItยทStatusยทzero_read_buffer;
-      }
-
-      if(it->write_size == 0){
-        fprintf( stderr ,"%s: Zero-sized write buffer\n" ,this_name );
-        status |= CopyยทWFItยทStatusยทzero_write_buffer;
-      }
-
-      if( Copyยทoverlap_size_interval(it->read0 ,it->read_size ,it->write0 ,it->write_size) ){
-        fprintf( stderr ,"%s: Read and write buffers overlap!\n" ,this_name );
-        status |= CopyยทWFItยทStatusยทoverlap;
-      }
-
-      return status;
-    }
-
-  #endif // LOCAL
-
-#endif // IMPLEMENTATION
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/N16.lib.c b/developer/deprecated๐Ÿ–‰/2025-03-29/N16.lib.c
new file mode 100644 (file)
index 0000000..561b43d
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+  N16 - a processor native type
+
+  For binary operations:  a op b -> c
+
+  See the document on the proper use of the Natural types.
+
+  On the subject of multiple pointers indicating the same location in memory:
+
+  When a routine has multiple results, and one or more of the result location
+  pointers point to the same storage, the routine will either return an error
+  status, or have defined behavior.
+
+  When a routine has multiple operands, in any combination, those
+  pointers can point to the same location, and the routine will
+  function as advertised.
+
+  When an operand functions as both an input and a result, perhaps due
+  to a result pointer pointing to the same place as an operand
+  pointer, the routine will function as advertised. (Internally the
+  routine might make a temporary copy of the operand to accomplish
+  this.)
+*/
+
+#define N16ยทDEBUG
+
+#ifndef FACE
+#define N16ยทIMPLEMENTATION
+#define FACE
+#endif
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef N16ยทFACE
+#define N16ยทFACE
+
+  #include <stdint.h>
+  #include <stdbool.h>
+  #include <stdarg.h>
+  #include <stdlib.h>
+
+  //----------------------------------------
+  // Instance Data (Declaration Only)
+
+  typedef uint16_t Extent;
+  typedef uint16_t Digit;
+
+  typedef struct N16ยทT N16ยทT;
+
+  extern N16ยทT *N16ยทzero;
+  extern N16ยทT *N16ยทone;
+  extern N16ยทT *N16ยทall_one_bit;
+  extern N16ยทT *N16ยทlsb;
+  extern N16ยทT *N16ยทmsb;
+
+  //----------------------------------------
+  // Return/Error Status and handlers
+
+  typedef enum{
+    N16ยทStatusยทok = 0
+   ,N16ยทStatusยทoverflow = 1
+   ,N16ยทStatusยทaccumulator1_overflow = 2
+   ,N16ยทStatusยทcarry = 3
+   ,N16ยทStatusยทborrow = 4
+   ,N16ยทStatusยทundefined_divide_by_zero = 5
+   ,N16ยทStatusยทundefined_modulus_zero = 6
+   ,N16ยทStatusยทgt_max_shift_count = 7
+   ,N16ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
+   ,N16ยทStatusยทone_word_product = 9
+   ,N16ยทStatusยทtwo_word_product = 10
+  } N16ยทStatus;
+
+  typedef enum{
+    N16ยทOrder_lt = -1
+   ,N16ยทOrder_eq = 0
+   ,N16ยทOrder_gt = 1
+  } N16ยทOrder;
+
+  typedef N16ยทT *( *N16ยทAllocate_MemoryFault )(Extent);
+
+  //----------------------------------------
+  // Interface
+
+  typedef struct{
+
+    N16ยทT *(*allocate_array_zero)(Extent, N16ยทAllocate_MemoryFault);
+    N16ยทT *(*allocate_array)(Extent, N16ยทAllocate_MemoryFault);
+    void (*deallocate)(N16ยทT*);
+
+    void (*copy)(N16ยทT*, N16ยทT*);
+    void (*bit_and)(N16ยทT*, N16ยทT*, N16ยทT*);
+    void (*bit_or)(N16ยทT*, N16ยทT*, N16ยทT*);
+    void (*bit_complement)(N16ยทT*, N16ยทT*);
+    void (*bit_twos_complement)(N16ยทT*, N16ยทT*);
+    N16ยทOrder (*compare)(N16ยทT*, N16ยทT*);
+    bool (*lt)(N16ยทT*, N16ยทT*);
+    bool (*gt)(N16ยทT*, N16ยทT*);
+    bool (*eq)(N16ยทT*, N16ยทT*);
+    bool (*eq_zero)(N16ยทT*);
+    N16ยทStatus (*accumulate)(N16ยทT *accumulator1 ,N16ยทT *accumulator0 ,...);
+    N16ยทStatus (*add)(N16ยทT*, N16ยทT*, N16ยทT*);
+    bool (*increment)(N16ยทT *a);
+    N16ยทStatus (*subtract)(N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*multiply)(N16ยทT*, N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*divide)(N16ยทT*, N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*modulus)(N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*shift_left)(Extent, N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*shift_right)(Extent, N16ยทT*, N16ยทT*, N16ยทT*);
+    N16ยทStatus (*arithmetic_shift_right)(Extent, N16ยทT*, N16ยทT*);
+
+    N16ยทT* (*access)(N16ยทT*, Extent);
+    void (*from_uint32)(N16ยทT *destination ,uint32_t value);
+  } N16ยทM;
+
+  Local const N16ยทM N16ยทm; // initialized in the LOCAL section
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef N16ยทIMPLEMENTATION
+
+  // this part goes into the library
+  #ifndef LOCAL
+
+    #include <stdarg.h>
+    #include <stdlib.h>
+
+    struct N16ยทT{
+      Digit d0;
+    };
+
+    N16ยทT N16ยทconstant[4] = {
+    {.d0 = 0},
+    {.d0 = 1},
+    {.d0 = ~(uint16_t)0},
+    {.d0 = 1 << 15}
+    };
+
+    N16ยทT *N16ยทzero = &N16ยทconstant[0];
+    N16ยทT *N16ยทone = &N16ยทconstant[1];
+    N16ยทT *N16ยทall_one_bit = &N16ยทconstant[2];
+    N16ยทT *N16ยทmsb = &N16ยทconstant[3];
+    N16ยทT *N16ยทlsb = &N16ยทconstant[1];
+
+    // the allocate an array of N16
+    N16ยทT *N16ยทallocate_array(Extent extent ,N16ยทAllocate_MemoryFault memory_fault){
+      N16ยทT *instance = malloc((extent + 1) * sizeof(N16ยทT));
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    N16ยทT *N16ยทallocate_array_zero(Extent extent ,N16ยทAllocate_MemoryFault memory_fault){
+      N16ยทT *instance = calloc(extent + 1, sizeof(N16ยทT));
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    void N16ยทdeallocate(N16ยทT *unencumbered){
+      free(unencumbered);
+    }
+
+
+  #endif
+
+  // This part is included after the library user's code
+  #ifdef LOCAL
+
+    // instance
+
+    struct N16ยทT{
+      Digit d0;
+    };
+
+    // temporary variables
+    Local N16ยทT N16ยทt[4];
+
+    // allocation 
+
+    extern N16ยทT *N16ยทallocate_array(Extent, N16ยทAllocate_MemoryFault);
+    extern N16ยทT *N16ยทallocate_array_zero(Extent, N16ยทAllocate_MemoryFault);
+    extern void N16ยทdeallocate(N16ยทT *);
+
+    // so the user can access numbers in an array allocation
+    Local N16ยทT* N16ยทaccess(N16ยทT *array ,Extent index){
+      return &array[index];
+    }
+
+    Local void N16ยทfrom_uint32(N16ยทT *destination ,uint32_t value){
+      if(destination == NULL) return;
+      destination->d0 = (uint16_t)(value & 0xFFFF);
+    }
+
+    // copy, convenience copy
+
+    Local void N16ยทcopy(N16ยทT *destination ,N16ยทT *source){
+      if(source == destination) return;
+      *destination = *source;
+    }
+
+    Local void N16ยทset_to_zero(N16ยทT *instance){
+      instance->d0 = 0;
+    }
+
+    Local void N16ยทset_to_one(N16ยทT *instance){
+      instance->d0 = 1;
+    }
+
+    // bit operations
+
+    Local void N16ยทbit_and(N16ยทT *result, N16ยทT *a, N16ยทT *b){
+      result->d0 = a->d0 & b->d0;
+    }
+
+    Local void N16ยทbit_or(N16ยทT *result, N16ยทT *a, N16ยทT *b){
+      result->d0 = a->d0 | b->d0;
+    }
+
+    Local void N16ยทbit_complement(N16ยทT *result, N16ยทT *a){
+      result->d0 = ~a->d0;
+    }
+
+    Local void N16ยทbit_twos_complement(N16ยทT *result ,N16ยทT *a){
+      result->d0 = (uint16_t)(~a->d0 + 1);
+    }
+
+    // test functions
+
+    Local N16ยทOrder N16ยทcompare(N16ยทT *a, N16ยทT *b){
+      if(a->d0 < b->d0) return N16ยทOrder_lt;
+      if(a->d0 > b->d0) return N16ยทOrder_gt;
+      return N16ยทOrder_eq;
+    }
+
+    Local bool N16ยทlt(N16ยทT *a ,N16ยทT *b){
+      return a->d0 < b->d0;
+    }    
+
+    Local bool N16ยทgt(N16ยทT *a ,N16ยทT *b){
+      return a->d0 > b->d0;
+    }    
+
+    Local bool N16ยทeq(N16ยทT *a ,N16ยทT *b){
+      return a->d0 == b->d0;
+    }    
+
+    Local bool N16ยทeq_zero(N16ยทT *a){
+      return a->d0 == 0;
+    }    
+
+    // arithmetic operations
+
+    Local N16ยทStatus N16ยทaccumulate(N16ยทT *accumulator1 ,N16ยทT *accumulator0 ,...){
+
+      va_list args;
+      va_start(args ,accumulator0);
+      uint32_t sum = accumulator0->d0;
+      uint32_t carry = 0;
+      N16ยทT *current;
+
+      while( (current = va_arg(args ,N16ยทT*)) ){
+        sum += current->d0;
+        if(sum < current->d0){
+          (carry)++;
+          if(carry == 0){
+            va_end(args);
+            return N16ยทStatusยทaccumulator1_overflow;
+          }
+        }
+      }
+      va_end(args);
+
+      accumulator1->d0 = (uint16_t)carry;
+      return N16ยทStatusยทok;
+    }
+
+    Local N16ยทStatus N16ยทadd(N16ยทT *sum ,N16ยทT *a ,N16ยทT *b){
+      uint32_t result = (uint32_t)a->d0 + (uint32_t)b->d0;
+      sum->d0 = (uint16_t)(result & 0xFFFF);
+      return (result >> 16) ? N16ยทStatusยทcarry : N16ยทStatusยทok;
+    }
+
+    Local bool N16ยทincrement(N16ยทT *a){
+      a->d0++;
+      return (a->d0 == 0);
+    }
+
+    Local N16ยทStatus N16ยทsubtract(N16ยทT *difference ,N16ยทT *a ,N16ยทT *b){
+      uint32_t diff = (uint32_t)a->d0 - (uint32_t)b->d0;
+      difference->d0 = (uint16_t)(diff & 0xFFFF);
+      return (diff > a->d0) ? N16ยทStatusยทborrow : N16ยทStatusยทok;
+    }
+
+    Local N16ยทStatus N16ยทmultiply(N16ยทT *product1 ,N16ยทT *product0 ,N16ยทT *a ,N16ยทT *b){
+      uint32_t product = (uint32_t)a->d0 * (uint32_t)b->d0;
+      product0->d0 = (uint16_t)(product & 0xFFFF);
+      product1->d0 = (uint16_t)((product >> 16) & 0xFFFF);
+
+      if(product1->d0 == 0) return N16ยทStatusยทone_word_product;
+      return N16ยทStatusยทtwo_word_product;
+    }
+
+    Local N16ยทStatus N16ยทdivide(N16ยทT *remainder ,N16ยทT *quotient ,N16ยทT *a ,N16ยทT *b){
+      if(b->d0 == 0) return N16ยทStatusยทundefined_divide_by_zero;
+
+      uint32_t dividend = a->d0;
+      uint32_t divisor = b->d0;
+      quotient->d0 = (uint16_t)(dividend / divisor);
+      remainder->d0 = (uint16_t)(dividend - (quotient->d0 * divisor));
+
+      return N16ยทStatusยทok;
+    }
+
+    Local N16ยทStatus N16ยทmodulus(N16ยทT *remainder ,N16ยทT *a ,N16ยทT *b){
+      if(b->d0 == 0) return N16ยทStatusยทundefined_modulus_zero;
+      uint32_t dividend = a->d0;
+      uint32_t divisor = b->d0;
+      uint32_t q = dividend / divisor;
+      remainder->d0 = (uint16_t)(dividend - (q * divisor));
+      return N16ยทStatusยทok;
+    }
+
+    // bit motion
+
+    typedef uint16_t (*ShiftOp)(uint16_t, uint16_t);
+
+    Local uint16_t shift_left_op(uint16_t value, uint16_t amount){
+      return value << amount;
+    }
+
+    Local uint16_t shift_right_op(uint16_t value, uint16_t amount){
+      return (uint16_t)(value >> amount);
+    }
+
+    Local N16ยทStatus N16ยทshift
+    (
+     uint16_t shift_count
+     ,N16ยทT *spill
+     ,N16ยทT *operand
+     ,N16ยทT *fill
+     ,ShiftOp shift_op
+     ,ShiftOp complement_shift_op
+    ){
+
+      if(operand == NULL && spill == NULL) return N16ยทStatusยทok;
+
+      if(operand == NULL){
+        operand = &N16ยทt[0];
+        N16ยทcopy(operand, N16ยทzero);
+      }
+
+      if(shift_count > 15) return N16ยทStatusยทgt_max_shift_count;
+
+      N16ยทT *given_operand = &N16ยทt[1];
+      N16ยทcopy(given_operand, operand);
+
+      operand->d0 = shift_op(given_operand->d0, shift_count);
+      if(fill != NULL){
+        fill->d0 = complement_shift_op(fill->d0, (16 - shift_count));
+        N16ยทbit_or(operand, operand, fill);
+      }
+      if(spill != NULL){
+        spill->d0 = shift_op(spill->d0, shift_count);
+        spill->d0 += complement_shift_op(given_operand->d0, (16 - shift_count));
+      }
+
+      return N16ยทStatusยทok;
+    }
+
+    Local N16ยทStatus 
+    N16ยทshift_left(uint16_t shift_count, N16ยทT *spill, N16ยทT *operand, N16ยทT *fill){
+      return N16ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
+    }
+
+    Local N16ยทStatus 
+    N16ยทshift_right(uint16_t shift_count, N16ยทT *spill, N16ยทT *operand, N16ยทT *fill){
+      return N16ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
+    }
+
+    Local N16ยทStatus 
+    N16ยทarithmetic_shift_right(uint16_t shift_count, N16ยทT *operand, N16ยทT *spill){
+
+      if(shift_count > 15) return N16ยทStatusยทgt_max_shift_count;
+
+      if(operand == NULL){
+        operand = &N16ยทt[0];
+        N16ยทcopy(operand, N16ยทzero);
+      }
+
+      N16ยทT *fill = (operand->d0 & 0x8000) ? N16ยทall_one_bit : N16ยทzero;
+      return N16ยทshift_right(shift_count, spill, operand, fill);
+    }
+
+    Local const N16ยทM N16ยทm = {
+
+      .allocate_array = N16ยทallocate_array
+     ,.allocate_array_zero = N16ยทallocate_array_zero
+     ,.deallocate = N16ยทdeallocate
+
+     ,.copy = N16ยทcopy
+     ,.bit_and = N16ยทbit_and
+     ,.bit_or = N16ยทbit_or
+     ,.bit_complement = N16ยทbit_complement
+     ,.bit_twos_complement = N16ยทbit_twos_complement
+     ,.compare = N16ยทcompare
+     ,.lt = N16ยทlt
+     ,.gt = N16ยทgt
+     ,.eq = N16ยทeq
+     ,.eq_zero = N16ยทeq_zero
+     ,.accumulate = N16ยทaccumulate
+     ,.add = N16ยทadd
+     ,.increment = N16ยทincrement
+     ,.subtract = N16ยทsubtract
+     ,.multiply = N16ยทmultiply
+     ,.divide = N16ยทdivide
+     ,.modulus = N16ยทmodulus
+     ,.shift_left = N16ยทshift_left
+     ,.shift_right = N16ยทshift_right
+     ,.arithmetic_shift_right = N16ยทarithmetic_shift_right
+
+     ,.access = N16ยทaccess
+     ,.from_uint32 = N16ยทfrom_uint32
+    };
+
+  #endif
+
+#endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/N32.lib.c b/developer/deprecated๐Ÿ–‰/2025-03-29/N32.lib.c
new file mode 100644 (file)
index 0000000..ccb3411
--- /dev/null
@@ -0,0 +1,457 @@
+/*
+  N32 - a processor native type
+
+  For binary operations:  a op b -> c
+
+  See the document on the proper use of the Natural types.
+
+  On the subject of multiple pointers indicating the same location in memory:
+
+  When a routine has multiple results, and one or more of the result location
+  pointers point to the same storage, the routine will either return an error
+  status, or have defined behavior.
+
+  When a routine has multiple operands, in any combination, those
+  pointers can point to the same location, and the routine will
+  function as advertised.
+
+  When an operand functions as both an input and a result, perhaps due
+  to a result pointer pointing to the same place as an operand
+  pointer, the routine will function as advertised. (Internally the
+  routine might make a temporary copy of the operand to accomplish
+  this.)
+
+*/
+
+#define N32ยทDEBUG
+
+#ifndef FACE
+#define N32ยทIMPLEMENTATION
+#define FACE
+#endif
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef N32ยทFACE
+#define N32ยทFACE
+
+  #include <stdint.h>
+  #include <stdbool.h>
+  #include <stdarg.h>
+  #include <stdlib.h>
+
+  //----------------------------------------
+  // Instance Data (Declaration Only)
+
+  typedef uint32_t Extent;
+  typedef uint32_t Digit;
+
+  typedef struct N32ยทT N32ยทT;
+
+  extern N32ยทT *N32ยทzero;
+  extern N32ยทT *N32ยทone;
+  extern N32ยทT *N32ยทall_one_bit;
+  extern N32ยทT *N32ยทlsb;
+  extern N32ยทT *N32ยทmsb;
+
+  //----------------------------------------
+  // Return/Error Status and handlers
+
+  typedef enum{
+    N32ยทStatusยทok = 0
+    ,N32ยทStatusยทoverflow = 1
+    ,N32ยทStatusยทaccumulator1_overflow = 2
+    ,N32ยทStatusยทcarry = 3
+    ,N32ยทStatusยทborrow = 4
+    ,N32ยทStatusยทundefined_divide_by_zero = 5
+    ,N32ยทStatusยทundefined_modulus_zero = 6
+    ,N32ยทStatusยทgt_max_shift_count = 7
+    ,N32ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
+    ,N32ยทStatusยทone_word_product = 9
+    ,N32ยทStatusยทtwo_word_product = 10
+  } N32ยทStatus;
+
+  typedef enum{
+    N32ยทOrder_lt = -1
+    ,N32ยทOrder_eq = 0
+    ,N32ยทOrder_gt = 1
+  } N32ยทOrder;
+
+  typedef N32ยทT *( *N32ยทAllocate_MemoryFault )(Extent);
+
+  //----------------------------------------
+  // Interface
+
+  typedef struct{
+
+    N32ยทT *(*allocate_array_zero)(Extent, N32ยทAllocate_MemoryFault);
+    N32ยทT *(*allocate_array)(Extent, N32ยทAllocate_MemoryFault);
+    void (*deallocate)(N32ยทT*);
+
+    void (*copy)(N32ยทT*, N32ยทT*);
+    void (*bit_and)(N32ยทT*, N32ยทT*, N32ยทT*);
+    void (*bit_or)(N32ยทT*, N32ยทT*, N32ยทT*);
+    void (*bit_complement)(N32ยทT*, N32ยทT*);
+    void (*bit_twos_complement)(N32ยทT*, N32ยทT*);
+    N32ยทOrder (*compare)(N32ยทT*, N32ยทT*);
+    bool (*lt)(N32ยทT*, N32ยทT*);
+    bool (*gt)(N32ยทT*, N32ยทT*);
+    bool (*eq)(N32ยทT*, N32ยทT*);
+    bool (*eq_zero)(N32ยทT*);
+    N32ยทStatus (*accumulate)(N32ยทT *accumulator1 ,N32ยทT *accumulator0 ,...);
+    N32ยทStatus (*add)(N32ยทT*, N32ยทT*, N32ยทT*);
+    bool (*increment)(N32ยทT *a);
+    N32ยทStatus (*subtract)(N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*multiply)(N32ยทT*, N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*divide)(N32ยทT*, N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*modulus)(N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*shift_left)(Extent, N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*shift_right)(Extent, N32ยทT*, N32ยทT*, N32ยทT*);
+    N32ยทStatus (*arithmetic_shift_right)(Extent, N32ยทT*, N32ยทT*);
+
+    N32ยทT* (*access)(N32ยทT*, Extent);
+    void (*from_uint32)(N32ยทT *destination ,uint32_t value);
+  } N32ยทM;
+
+  Local const N32ยทM N32ยทm; // initialized in the LOCAL section
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef N32ยทIMPLEMENTATION
+
+  // this part goes into the library
+  #ifndef LOCAL
+
+    #include <stdarg.h>
+    #include <stdlib.h>
+
+    struct N32ยทT{
+      Digit d0;
+    };
+
+    N32ยทT N32ยทconstant[4] = {
+      {.d0 = 0},
+      {.d0 = 1},
+      {.d0 = ~(uint32_t)0},
+      {.d0 = 1 << 31}
+    };
+
+    N32ยทT *N32ยทzero = &N32ยทconstant[0];
+    N32ยทT *N32ยทone = &N32ยทconstant[1];
+    N32ยทT *N32ยทall_one_bit = &N32ยทconstant[2];
+    N32ยทT *N32ยทmsb = &N32ยทconstant[3];
+    N32ยทT *N32ยทlsb = &N32ยทconstant[1];
+
+    // the allocate an array of N32
+    N32ยทT *N32ยทallocate_array(Extent extent ,N32ยทAllocate_MemoryFault memory_fault){
+      N32ยทT *instance = malloc((extent + 1) * sizeof(N32ยทT) );
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    N32ยทT *N32ยทallocate_array_zero(Extent extent ,N32ยทAllocate_MemoryFault memory_fault){
+      N32ยทT *instance = calloc( extent + 1 ,sizeof(N32ยทT) );
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    void N32ยทdeallocate(N32ยทT *unencumbered){
+      free(unencumbered);
+    }
+
+  #endif
+
+  // This part is included after the library user's code
+  #ifdef LOCAL
+
+    // instance
+
+    struct N32ยทT{
+      Digit d0;
+    };
+
+    // temporary variables
+    // making these LOCAL rather than reserving one block in the library is thread safe
+    // allocating a block once is more efficient
+    // library code writes these, they are not on the interface
+
+    Local N32ยทT N32ยทt[4];
+
+
+    // allocation 
+
+    extern N32ยทT *N32ยทallocate_array(Extent, N32ยทAllocate_MemoryFault);
+    extern N32ยทT *N32ยทallocate_array_zero(Extent, N32ยทAllocate_MemoryFault);
+    extern void N32ยทdeallocate(N32ยทT *);
+
+    // so the user can access numbers in an array allocation
+    Local N32ยทT* N32ยทaccess(N32ยทT *array ,Extent index){
+      return &array[index];
+    }
+
+    Local void N32ยทfrom_uint32(N32ยทT *destination ,uint32_t value){
+      if(destination == NULL) return;
+      destination->d0 = value;
+    }
+
+    // copy, convenience copy
+
+    Local void N32ยทcopy(N32ยทT *destination ,N32ยทT *source){
+      if(source == destination) return; // that was easy! 
+      *destination = *source;
+    }
+
+    Local void N32ยทset_to_zero(N32ยทT *instance){
+      instance->d0 = 0;
+    }
+
+    Local void N32ยทset_to_one(N32ยทT *instance){
+      instance->d0 = 1;
+    }
+
+    // bit operations
+
+    Local void N32ยทbit_and(N32ยทT *result, N32ยทT *a, N32ยทT *b){
+      result->d0 = a->d0 & b->d0;
+    }
+
+    // result can be one of the operands
+    Local void N32ยทbit_or(N32ยทT *result, N32ยทT *a, N32ยทT *b){
+      result->d0 = a->d0 | b->d0;
+    }
+
+    // result can the same as the operand
+    Local void N32ยทbit_complement(N32ยทT *result, N32ยทT *a){
+      result->d0 = ~a->d0;
+    }
+
+    // result can the same as the operand
+    Local void N32ยทbit_twos_complement(N32ยทT *result ,N32ยทT *a){
+      result->d0 = ~a->d0 + 1;
+    }
+
+    // test functions
+
+    Local N32ยทOrder N32ยทcompare(N32ยทT *a, N32ยทT *b){
+      if(a->d0 < b->d0) return N32ยทOrder_lt;
+      if(a->d0 > b->d0) return N32ยทOrder_gt;
+      return N32ยทOrder_eq;
+    }
+
+    Local bool N32ยทlt(N32ยทT *a ,N32ยทT *b){
+      return  a->d0 < b->d0;
+    }    
+
+    Local bool N32ยทgt(N32ยทT *a ,N32ยทT *b){
+      return  a->d0 > b->d0;
+    }    
+
+    Local bool N32ยทeq(N32ยทT *a ,N32ยทT *b){
+      return  a->d0 == b->d0;
+    }    
+
+    Local bool N32ยทeq_zero(N32ยทT *a){
+      return  a->d0 == 0;
+    }    
+
+
+    // arithmetic operations
+
+    // For a large number of summands for the lower precision Natural implementations, for accumulate/add/sub, the 'overflow' operand could overflow and thus this routine will halt and return N32ยทStatusยทaccumulator1_overflow
+    //
+    // When accumulator1 and accumulator0 point to the same location, the result is the accumulator1 value.
+    Local N32ยทStatus N32ยทaccumulate(N32ยทT *accumulator1 ,N32ยทT *accumulator0 ,...){
+
+      va_list args;
+      va_start(args ,accumulator0);
+      uint32_t sum = accumulator0->d0;
+      uint32_t carry = 0;
+      N32ยทT *current;
+
+      while( (current = va_arg(args ,N32ยทT *)) ){
+        sum += current->d0;
+        if(sum < current->d0){  // Accumulator1 into carry
+          (carry)++;
+          if(carry == 0){
+            va_end(args);
+            return N32ยทStatusยทaccumulator1_overflow;
+          }
+        }
+      }
+      va_end(args);
+
+      // wipes out prior value of accumulator1
+      accumulator1->d0 = carry;
+
+      return N32ยทStatusยทok;
+    }
+
+    Local N32ยทStatus N32ยทadd(N32ยทT *sum ,N32ยทT *a ,N32ยทT *b){
+      uint64_t result = (uint64_t)a->d0 + (uint64_t)b->d0;
+      sum->d0 = (uint32_t)result;
+      return (result >> 32) ? N32ยทStatusยทcarry : N32ยทStatusยทok;
+    }
+
+    Local bool N32ยทincrement(N32ยทT *a){
+      a->d0++;
+      return a->d0 == 0;
+    }
+
+    Local N32ยทStatus N32ยทsubtract(N32ยทT *difference ,N32ยทT *a ,N32ยทT *b){
+      uint64_t diff = (uint64_t) a->d0 - (uint64_t) b->d0;
+      difference->d0 = (uint32_t)diff;
+      return (diff > a->d0) ? N32ยทStatusยทborrow : N32ยทStatusยทok;
+    }
+
+
+    Local N32ยทStatus N32ยทmultiply(N32ยทT *product1 ,N32ยทT *product0 ,N32ยทT *a ,N32ยทT *b){
+      uint64_t product = (uint64_t)a->d0 * (uint64_t)b->d0;
+      product0->d0 = (uint32_t)product;
+      product1->d0 = (uint32_t)(product >> 32);
+
+      if(product1->d0 == 0) return N32ยทStatusยทone_word_product;
+      return N32ยทStatusยทtwo_word_product;
+    }
+
+    Local N32ยทStatus N32ยทdivide(N32ยทT *remainder ,N32ยทT *quotient ,N32ยทT *a ,N32ยทT *b){
+      if(b->d0 == 0) return N32ยทStatusยทundefined_divide_by_zero; 
+
+      quotient->d0 = a->d0 / b->d0;
+      remainder->d0 = a->d0 - (quotient->d0 * b->d0);
+
+      return N32ยทStatusยทok;
+    }
+
+    Local N32ยทStatus N32ยทmodulus(N32ยทT *remainder ,N32ยทT *a ,N32ยทT *b){
+      if(b->d0 == 0) return N32ยทStatusยทundefined_modulus_zero; 
+      uint32_t quotient = a->d0 / b->d0;
+      remainder->d0 = a->d0 - (quotient * b->d0);
+      return N32ยทStatusยทok;
+    }
+
+    // bit motion
+
+    typedef uint32_t (*ShiftOp)(uint32_t, uint32_t);
+
+    Local uint32_t shift_left_op(uint32_t value, uint32_t amount){
+      return value << amount;
+    }
+
+    Local uint32_t shift_right_op(uint32_t value, uint32_t amount){
+      return value >> amount;
+    }
+
+    // modifies all three of its operands
+    // in the case of duplicate operands this is the order: first modifies operand, then fill, then spill, 
+    Local N32ยทStatus N32ยทshift
+    (
+     uint32_t shift_count
+     ,N32ยทT *spill
+     ,N32ยทT *operand
+     ,N32ยทT *fill
+     ,ShiftOp shift_op
+     ,ShiftOp complement_shift_op
+     ){
+
+      // If no result is needed, return immediately.
+      if(operand == NULL && spill == NULL) return N32ยทStatusยทok;
+
+      // Treat NULL operand as zero.
+      if(operand == NULL){
+        operand = &N32ยทt[0];
+        N32ยทcopy(operand, N32ยทzero);
+      }
+
+      // Shifting more than one word breaks our fill/spill model.
+      if(shift_count > 31) return N32ยทStatusยทgt_max_shift_count;
+
+      // The given operand is still required after it is modified, so we copy it.
+      N32ยทT *given_operand = &N32ยทt[1];
+      N32ยทcopy(given_operand, operand);
+
+      // Perform the shift
+      operand->d0 = shift_op(given_operand->d0, shift_count);
+      if(fill != NULL){
+        fill->d0 = complement_shift_op(fill->d0, (32 - shift_count));
+        N32ยทbit_or(operand, operand, fill);
+      }
+      if(spill != NULL){
+        spill->d0 = shift_op(spill->d0, shift_count);
+        spill->d0 += complement_shift_op(given_operand->d0, (32 - shift_count));
+      }
+
+      return N32ยทStatusยทok;
+    }
+
+    // Define concrete shift functions using valid C function pointers
+    Local N32ยทStatus 
+    N32ยทshift_left(uint32_t shift_count, N32ยทT *spill, N32ยทT *operand, N32ยทT *fill){
+      return N32ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
+    }
+
+    Local N32ยทStatus 
+    N32ยทshift_right(uint32_t shift_count, N32ยทT *spill, N32ยทT *operand, N32ยทT *fill){
+      return N32ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
+    }
+
+    Local N32ยทStatus 
+    N32ยทarithmetic_shift_right(uint32_t shift_count, N32ยทT *operand, N32ยทT *spill){
+
+      // Guard against excessive shift counts
+      if(shift_count > 31) return N32ยทStatusยทgt_max_shift_count;
+
+      // A NULL operand is treated as zero
+      if(operand == NULL){
+        operand = &N32ยทt[0];
+        N32ยทcopy(operand, N32ยทzero);
+      }
+
+      // Pick the fill value based on the sign bit
+      N32ยทT *fill = (operand->d0 & 0x80000000) ? N32ยทall_one_bit : N32ยทzero;
+
+      // Call shift_right with the appropriate fill
+      return N32ยทshift_right(shift_count, spill, operand, fill);
+    }
+
+    Local const N32ยทM N32ยทm = {
+
+      .allocate_array = N32ยทallocate_array
+      ,.allocate_array_zero = N32ยทallocate_array_zero
+      ,.deallocate = N32ยทdeallocate
+
+      ,.copy = N32ยทcopy
+      ,.bit_and = N32ยทbit_and
+      ,.bit_or = N32ยทbit_or
+      ,.bit_complement = N32ยทbit_complement
+      ,.bit_twos_complement = N32ยทbit_twos_complement
+      ,.compare = N32ยทcompare
+      ,.lt = N32ยทlt
+      ,.gt = N32ยทgt
+      ,.eq = N32ยทeq
+      ,.eq_zero = N32ยทeq_zero
+      ,.accumulate = N32ยทaccumulate
+      ,.add = N32ยทadd
+      ,.increment = N32ยทincrement
+      ,.subtract = N32ยทsubtract
+      ,.multiply = N32ยทmultiply
+      ,.divide = N32ยทdivide
+      ,.modulus = N32ยทmodulus
+      ,.shift_left = N32ยทshift_left
+      ,.shift_right = N32ยทshift_right
+      ,.arithmetic_shift_right = N32ยทarithmetic_shift_right
+
+      ,.access = N32ยทaccess
+      ,.from_uint32 = N32ยทfrom_uint32
+    };
+
+  #endif
+
+#endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/N64.lib.c b/developer/deprecated๐Ÿ–‰/2025-03-29/N64.lib.c
new file mode 100644 (file)
index 0000000..6058e9b
--- /dev/null
@@ -0,0 +1,477 @@
+/*
+  N64 - a 64-bit native type
+
+  For binary operations: a op b -> c
+
+  Similar to N32, but now each Digit is 64 bits. Where a 128-bit
+  intermediate is necessary (e.g. multiplication), we handle it
+  manually using two 64-bit parts.
+
+  On the subject of multiple pointers indicating the same location in memory:
+
+  When a routine has multiple results, and one or more of the result location
+  pointers point to the same storage, the routine will either return an error
+  status, or have defined behavior.
+
+  When a routine has multiple operands, in any combination, those
+  pointers can point to the same location, and the routine will
+  function as advertised.
+
+  When an operand functions as both an input and a result, perhaps due
+  to a result pointer pointing to the same place as an operand
+  pointer, the routine will function as advertised. (Internally the
+  routine might make a temporary copy of the operand to accomplish
+  this.)
+*/
+
+#define N64ยทDEBUG
+
+#ifndef FACE
+#define N64ยทIMPLEMENTATION
+#define FACE
+#endif
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef N64ยทFACE
+#define N64ยทFACE
+
+  #include <stdint.h>
+  #include <stdbool.h>
+  #include <stdarg.h>
+  #include <stdlib.h>
+
+  //----------------------------------------
+  // Instance Data (Declaration Only)
+
+  typedef uint64_t Extent;
+  typedef uint64_t Digit;
+
+  typedef struct N64ยทT N64ยทT;
+
+  extern N64ยทT *N64ยทzero;
+  extern N64ยทT *N64ยทone;
+  extern N64ยทT *N64ยทall_one_bit;
+  extern N64ยทT *N64ยทlsb;
+  extern N64ยทT *N64ยทmsb;
+
+  //----------------------------------------
+  // Return/Error Status and handlers
+
+  typedef enum {
+    N64ยทStatusยทok = 0
+   ,N64ยทStatusยทoverflow = 1
+   ,N64ยทStatusยทaccumulator1_overflow = 2
+   ,N64ยทStatusยทcarry = 3
+   ,N64ยทStatusยทborrow = 4
+   ,N64ยทStatusยทundefined_divide_by_zero = 5
+   ,N64ยทStatusยทundefined_modulus_zero = 6
+   ,N64ยทStatusยทgt_max_shift_count = 7
+   ,N64ยทStatusยทspill_eq_operand = 8 // not currently signaled, result will be spill value
+   ,N64ยทStatusยทone_word_product = 9
+   ,N64ยทStatusยทtwo_word_product = 10
+  } N64ยทStatus;
+
+  typedef enum {
+    N64ยทOrder_lt = -1
+   ,N64ยทOrder_eq = 0
+   ,N64ยทOrder_gt = 1
+  } N64ยทOrder;
+
+  typedef N64ยทT *(*N64ยทAllocate_MemoryFault)(Extent);
+
+  //----------------------------------------
+  // Interface
+
+  typedef struct {
+
+    N64ยทT *(*allocate_array_zero)(Extent, N64ยทAllocate_MemoryFault);
+    N64ยทT *(*allocate_array)(Extent, N64ยทAllocate_MemoryFault);
+    void   (*deallocate)(N64ยทT*);
+
+    void        (*copy)(N64ยทT*, N64ยทT*);
+    void        (*bit_and)(N64ยทT*, N64ยทT*, N64ยทT*);
+    void        (*bit_or)(N64ยทT*, N64ยทT*, N64ยทT*);
+    void        (*bit_complement)(N64ยทT*, N64ยทT*);
+    void        (*bit_twos_complement)(N64ยทT*, N64ยทT*);
+    N64ยทOrder   (*compare)(N64ยทT*, N64ยทT*);
+    bool        (*lt)(N64ยทT*, N64ยทT*);
+    bool        (*gt)(N64ยทT*, N64ยทT*);
+    bool        (*eq)(N64ยทT*, N64ยทT*);
+    bool        (*eq_zero)(N64ยทT*);
+    N64ยทStatus  (*accumulate)(N64ยทT *accumulator1, N64ยทT *accumulator0, ...);
+    N64ยทStatus  (*add)(N64ยทT*, N64ยทT*, N64ยทT*);
+    bool        (*increment)(N64ยทT *a);
+    N64ยทStatus  (*subtract)(N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*multiply)(N64ยทT*, N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*divide)(N64ยทT*, N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*modulus)(N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*shift_left)(Extent, N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*shift_right)(Extent, N64ยทT*, N64ยทT*, N64ยทT*);
+    N64ยทStatus  (*arithmetic_shift_right)(Extent, N64ยทT*, N64ยทT*);
+
+    N64ยทT*      (*access)(N64ยทT*, Extent);
+    void        (*from_uint64)(N64ยทT *destination, uint64_t value);
+
+  } N64ยทM;
+
+  Local const N64ยทM N64ยทm; // initialized in the LOCAL section
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef N64ยทIMPLEMENTATION
+
+  // this part goes into the library
+  #ifndef LOCAL
+
+    #include <stdarg.h>
+    #include <stdlib.h>
+
+    struct N64ยทT {
+      Digit d0;
+    };
+
+    // For constants, we store them in an array for convenience
+    // 0, 1, all bits set (~0ULL), and MSB set (1ULL<<63)
+    N64ยทT N64ยทconstant[4] = {
+      {.d0 = 0ULL},
+      {.d0 = 1ULL},
+      {.d0 = ~(uint64_t)0ULL},
+      {.d0 = 1ULL << 63}
+    };
+
+    N64ยทT *N64ยทzero = &N64ยทconstant[0];
+    N64ยทT *N64ยทone = &N64ยทconstant[1];
+    N64ยทT *N64ยทall_one_bit = &N64ยทconstant[2];
+    N64ยทT *N64ยทmsb = &N64ยทconstant[3];
+    N64ยทT *N64ยทlsb = &N64ยทconstant[1];
+
+    // allocate an array of N64
+    N64ยทT *N64ยทallocate_array(Extent extent, N64ยทAllocate_MemoryFault memory_fault){
+      N64ยทT *instance = malloc( (extent + 1) * sizeof(N64ยทT) );
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    N64ยทT *N64ยทallocate_array_zero(Extent extent, N64ยทAllocate_MemoryFault memory_fault){
+      N64ยทT *instance = calloc(extent + 1, sizeof(N64ยทT));
+      if(!instance){
+        return memory_fault ? memory_fault(extent) : NULL;
+      }
+      return instance;
+    }
+
+    void N64ยทdeallocate(N64ยทT *unencumbered){
+      free(unencumbered);
+    }
+
+  #endif
+
+  // This part is included after the library user's code
+  #ifdef LOCAL
+
+    // instance
+
+    struct N64ยทT {
+      Digit d0;
+    };
+
+    // local temporary variables
+    Local N64ยทT N64ยทt[4];
+
+    // allocation references
+    extern N64ยทT *N64ยทallocate_array(Extent, N64ยทAllocate_MemoryFault);
+    extern N64ยทT *N64ยทallocate_array_zero(Extent, N64ยทAllocate_MemoryFault);
+    extern void   N64ยทdeallocate(N64ยทT *);
+
+    // Access array
+    Local N64ยทT* N64ยทaccess(N64ยทT *array, Extent index){
+      return &array[index];
+    }
+
+    Local void N64ยทfrom_uint64(N64ยทT *destination, uint64_t value){
+      if(destination == NULL) return;
+      destination->d0 = value;
+    }
+
+    // copy
+    Local void N64ยทcopy(N64ยทT *destination, N64ยทT *source){
+      if(source == destination) return;
+      *destination = *source;
+    }
+
+    // bit operations
+
+    Local void N64ยทbit_and(N64ยทT *result, N64ยทT *a, N64ยทT *b){
+      result->d0 = a->d0 & b->d0;
+    }
+
+    Local void N64ยทbit_or(N64ยทT *result, N64ยทT *a, N64ยทT *b){
+      result->d0 = a->d0 | b->d0;
+    }
+
+    Local void N64ยทbit_complement(N64ยทT *result, N64ยทT *a){
+      result->d0 = ~a->d0;
+    }
+
+    Local void N64ยทbit_twos_complement(N64ยทT *result, N64ยทT *a){
+      result->d0 = ~a->d0 + 1ULL;
+    }
+
+    // compare & test functions
+
+    Local N64ยทOrder N64ยทcompare(N64ยทT *a, N64ยทT *b){
+      if(a->d0 < b->d0) return N64ยทOrder_lt;
+      if(a->d0 > b->d0) return N64ยทOrder_gt;
+      return N64ยทOrder_eq;
+    }
+
+    Local bool N64ยทlt(N64ยทT *a, N64ยทT *b){
+      return (a->d0 < b->d0);
+    }
+
+    Local bool N64ยทgt(N64ยทT *a, N64ยทT *b){
+      return (a->d0 > b->d0);
+    }
+
+    Local bool N64ยทeq(N64ยทT *a, N64ยทT *b){
+      return (a->d0 == b->d0);
+    }
+
+    Local bool N64ยทeq_zero(N64ยทT *a){
+      return (a->d0 == 0ULL);
+    }
+
+    // arithmetic operations
+
+    // accumulate
+    Local N64ยทStatus N64ยทaccumulate(N64ยทT *accumulator1, N64ยทT *accumulator0, ...){
+      va_list args;
+      va_start(args, accumulator0);
+
+      uint64_t sum = accumulator0->d0;
+      uint64_t carry = 0;
+      N64ยทT *current;
+
+      while( (current = va_arg(args, N64ยทT*)) ){
+        uint64_t prior = sum;
+        sum += current->d0;
+        if(sum < prior){  // indicates carry
+          carry++;
+          // if carry overflowed a 64-bit, that's an accumulator1 overflow
+          if(carry == 0ULL){
+            va_end(args);
+            return N64ยทStatusยทaccumulator1_overflow;
+          }
+        }
+      }
+      va_end(args);
+
+      accumulator1->d0 = carry;
+      return N64ยทStatusยทok;
+    }
+
+    // add
+    Local N64ยทStatus N64ยทadd(N64ยทT *sum, N64ยทT *a, N64ยทT *b){
+      __uint128_t result = ( __uint128_t )a->d0 + ( __uint128_t )b->d0;
+      // But to avoid using a GNU extension, we can do the simpler approach:
+      // Actually let's do it directly with 64-bit since we only need to detect carry out of 64 bits:
+      uint64_t temp = a->d0 + b->d0;
+      sum->d0 = temp;
+      if(temp < a->d0) return N64ยทStatusยทcarry;  // means we overflowed
+      return N64ยทStatusยทok;
+    }
+
+    Local bool N64ยทincrement(N64ยทT *a){
+      uint64_t old = a->d0;
+      a->d0++;
+      // if it wrapped around to 0, then it was 0xFFFFFFFFFFFFFFFF
+      return (a->d0 < old);
+    }
+
+    // subtract
+    Local N64ยทStatus N64ยทsubtract(N64ยทT *difference, N64ยทT *a, N64ยทT *b){
+      uint64_t tmpA = a->d0;
+      uint64_t tmpB = b->d0;
+      uint64_t diff = tmpA - tmpB;
+      difference->d0 = diff;
+      if(diff > tmpA) return N64ยทStatusยทborrow; // indicates we borrowed
+      return N64ยทStatusยทok;
+    }
+
+    // multiply
+    // We'll do a 64x64->128 using two 64-bit accumulators
+    Local N64ยทStatus N64ยทmultiply(N64ยทT *product1, N64ยทT *product0, N64ยทT *a, N64ยทT *b){
+      uint64_t A = a->d0;
+      uint64_t B = b->d0;
+
+      // Break each operand into high & low 32 bits
+      uint64_t a_lo = (uint32_t)(A & 0xffffffffULL);
+      uint64_t a_hi = A >> 32;
+      uint64_t b_lo = (uint32_t)(B & 0xffffffffULL);
+      uint64_t b_hi = B >> 32;
+
+      // partial products
+      uint64_t low = a_lo * b_lo;                   // 64-bit
+      uint64_t cross = (a_lo * b_hi) + (a_hi * b_lo); // potentially up to 2 * 32 bits => 64 bits
+      uint64_t high = a_hi * b_hi;                  // up to 64 bits
+
+      // incorporate cross into low, high
+      // cross is effectively the middle bits, so shift cross by 32 and add to low
+      uint64_t cross_low = (cross & 0xffffffffULL) << 32;  // lower part
+      uint64_t cross_high = cross >> 32;                   // upper part
+
+      // add cross_low to low, capture carry
+      uint64_t old_low = low;
+      low += cross_low;
+      if(low < old_low) cross_high++;
+
+      // final high
+      high += cross_high;
+
+      // store results
+      product0->d0 = low;
+      product1->d0 = high;
+
+      if(high == 0ULL) return N64ยทStatusยทone_word_product;
+      return N64ยทStatusยทtwo_word_product;
+    }
+
+    // divide
+    Local N64ยทStatus N64ยทdivide(N64ยทT *remainder, N64ยทT *quotient, N64ยทT *a, N64ยทT *b){
+      // we do not handle a > 64-bit, just the single 64-bit
+      if(b->d0 == 0ULL) return N64ยทStatusยทundefined_divide_by_zero;
+
+      uint64_t divd = a->d0; // dividend
+      uint64_t divs = b->d0; // divisor
+
+      quotient->d0 = divd / divs;
+      remainder->d0 = divd - (quotient->d0 * divs);
+
+      return N64ยทStatusยทok;
+    }
+
+    // modulus
+    Local N64ยทStatus N64ยทmodulus(N64ยทT *remainder, N64ยทT *a, N64ยทT *b){
+      if(b->d0 == 0ULL) return N64ยทStatusยทundefined_modulus_zero;
+
+      uint64_t divd = a->d0;
+      uint64_t divs = b->d0;
+      uint64_t q = divd / divs;
+      remainder->d0 = divd - (q * divs);
+
+      return N64ยทStatusยทok;
+    }
+
+    // bit motion
+
+    typedef uint64_t (*ShiftOp)(uint64_t, uint64_t);
+
+    Local uint64_t shift_left_op(uint64_t value, uint64_t amount){
+      return (value << amount);
+    }
+
+    Local uint64_t shift_right_op(uint64_t value, uint64_t amount){
+      return (value >> amount);
+    }
+
+    // modifies all three of its operands
+    // in the case of duplicate operands this is the order: first modifies operand, then fill, then spill
+    Local N64ยทStatus N64ยทshift
+    (
+     uint64_t shift_count,
+     N64ยทT *spill,
+     N64ยทT *operand,
+     N64ยทT *fill,
+     ShiftOp shift_op,
+     ShiftOp complement_shift_op
+    ){
+      if(operand == NULL && spill == NULL) return N64ยทStatusยทok;
+
+      // Treat NULL operand as zero
+      if(operand == NULL){
+        operand = &N64ยทt[0];
+        N64ยทcopy(operand, N64ยทzero);
+      }
+
+      // Shifting more than 63 bits breaks fill/spill logic
+      if(shift_count > 63ULL) return N64ยทStatusยทgt_max_shift_count;
+
+      N64ยทT *given_operand = &N64ยทt[1];
+      N64ยทcopy(given_operand, operand);
+
+      // Perform the shift
+      operand->d0 = shift_op(given_operand->d0, shift_count);
+      if(fill != NULL){
+        fill->d0 = complement_shift_op(fill->d0, (64ULL - shift_count));
+        N64ยทbit_or(operand, operand, fill);
+      }
+      if(spill != NULL){
+        spill->d0 = shift_op(spill->d0, shift_count);
+        spill->d0 += complement_shift_op(given_operand->d0, (64ULL - shift_count));
+      }
+
+      return N64ยทStatusยทok;
+    }
+
+    Local N64ยทStatus N64ยทshift_left(uint64_t shift_count, N64ยทT *spill, N64ยทT *operand, N64ยทT *fill){
+      return N64ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
+    }
+
+    Local N64ยทStatus N64ยทshift_right(uint64_t shift_count, N64ยทT *spill, N64ยทT *operand, N64ยทT *fill){
+      return N64ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
+    }
+
+    Local N64ยทStatus N64ยทarithmetic_shift_right(uint64_t shift_count, N64ยทT *operand, N64ยทT *spill){
+      if(shift_count > 63ULL) return N64ยทStatusยทgt_max_shift_count;
+
+      // A NULL operand is treated as zero
+      if(operand == NULL){
+        operand = &N64ยทt[0];
+        N64ยทcopy(operand, N64ยทzero);
+      }
+
+      // sign bit check
+      N64ยทT *fill = (operand->d0 & (1ULL << 63)) ? N64ยทall_one_bit : N64ยทzero;
+      return N64ยทshift_right(shift_count, spill, operand, fill);
+    }
+
+    Local const N64ยทM N64ยทm = {
+      .allocate_array = N64ยทallocate_array
+     ,.allocate_array_zero = N64ยทallocate_array_zero
+     ,.deallocate = N64ยทdeallocate
+
+     ,.copy = N64ยทcopy
+     ,.bit_and = N64ยทbit_and
+     ,.bit_or = N64ยทbit_or
+     ,.bit_complement = N64ยทbit_complement
+     ,.bit_twos_complement = N64ยทbit_twos_complement
+     ,.compare = N64ยทcompare
+     ,.lt = N64ยทlt
+     ,.gt = N64ยทgt
+     ,.eq = N64ยทeq
+     ,.eq_zero = N64ยทeq_zero
+     ,.accumulate = N64ยทaccumulate
+     ,.add = N64ยทadd
+     ,.increment = N64ยทincrement
+     ,.subtract = N64ยทsubtract
+     ,.multiply = N64ยทmultiply
+     ,.divide = N64ยทdivide
+     ,.modulus = N64ยทmodulus
+     ,.shift_left = N64ยทshift_left
+     ,.shift_right = N64ยทshift_right
+     ,.arithmetic_shift_right = N64ยทarithmetic_shift_right
+
+     ,.access = N64ยทaccess
+     ,.from_uint64 = N64ยทfrom_uint64
+    };
+
+  #endif
+
+#endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/N8.lib.c b/developer/deprecated๐Ÿ–‰/2025-03-29/N8.lib.c
new file mode 100644 (file)
index 0000000..df6e01c
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+  N8 - PN = refers to the use of processor native accumulator 
+
+  For binary operations:  a op b -> c
+
+  See the document on the proper use of the Natural types.
+
+  On the subject of multiple pointers indicating the same location in memory:
+
+  When a routine has multiple results, and one or more of the result location
+  pointers point to the same storage, the routine will either return an error
+  status, or have defined behavior.
+
+  When a routine has multiple operands, in any combination, those
+  pointers can point to the same location, and the routine will
+  function as advertised.
+
+  When an operand functions as both an input and a result, perhaps due
+  to a result pointer pointing to the same place as an operand
+  pointer, the routine will function as advertised. (Internally the
+  routine might make a temporary copy of the operand to accomplish
+  this.)
+*/
+
+#define N8ยทDEBUG
+
+#ifndef FACE
+#define N8ยทIMPLEMENTATION
+#define FACE
+#endif
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef N8ยทFACE
+#define N8ยทFACE
+
+  #include <stdint.h>
+  #include <stdbool.h>
+  #include <stdarg.h>
+  #include <stdlib.h>
+
+  //----------------------------------------
+  // Instance Data (Declaration Only)
+
+  typedef uint8_t Extent;
+  typedef uint8_t Digit;
+
+  typedef struct N8ยทT N8ยทT;
+
+  extern N8ยทT *N8ยทzero;
+  extern N8ยทT *N8ยทone;
+  extern N8ยทT *N8ยทall_one_bit;
+  extern N8ยทT *N8ยทlsb;
+  extern N8ยทT *N8ยทmsb;
+
+  //----------------------------------------
+  // Return/Error Status and handlers
+
+  typedef enum{
+    N8ยทStatusยทok = 0
+   ,N8ยทStatusยทoverflow = 1
+   ,N8ยทStatusยทaccumulator1_overflow = 2
+   ,N8ยทStatusยทcarry = 3
+   ,N8ยทStatusยทborrow = 4
+   ,N8ยทStatusยทundefined_divide_by_zero = 5
+   ,N8ยทStatusยทundefined_modulus_zero = 6
+   ,N8ยทStatusยทgt_max_shift_count = 7
+   ,N8ยทStatusยทspill_eq_operand = 8
+   ,N8ยทStatusยทone_word_product = 9
+   ,N8ยทStatusยทtwo_word_product = 10
+  } N8ยทStatus;
+
+  typedef enum{
+    N8ยทOrder_lt = -1
+   ,N8ยทOrder_eq = 0
+   ,N8ยทOrder_gt = 1
+  } N8ยทOrder;
+
+  typedef N8ยทT *( *N8ยทAllocate_MemoryFault )(Extent);
+
+  //----------------------------------------
+  // Interface
+
+  typedef struct{
+
+    N8ยทT *(*allocate_array_zero)(Extent, N8ยทAllocate_MemoryFault);
+    N8ยทT *(*allocate_array)(Extent, N8ยทAllocate_MemoryFault);
+    void (*deallocate)(N8ยทT*);
+
+    void (*copy)(N8ยทT*, N8ยทT*);
+    void (*bit_and)(N8ยทT*, N8ยทT*, N8ยทT*);
+    void (*bit_or)(N8ยทT*, N8ยทT*, N8ยทT*);
+    void (*bit_complement)(N8ยทT*, N8ยทT*);
+    void (*bit_twos_complement)(N8ยทT*, N8ยทT*);
+    N8ยทOrder (*compare)(N8ยทT*, N8ยทT*);
+    bool (*lt)(N8ยทT*, N8ยทT*);
+    bool (*gt)(N8ยทT*, N8ยทT*);
+    bool (*eq)(N8ยทT*, N8ยทT*);
+    bool (*eq_zero)(N8ยทT*);
+    N8ยทStatus (*accumulate)(N8ยทT *accumulator1 ,N8ยทT *accumulator0 ,...);
+    N8ยทStatus (*add)(N8ยทT*, N8ยทT*, N8ยทT*);
+    bool (*increment)(N8ยทT *a);
+    N8ยทStatus (*subtract)(N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*multiply)(N8ยทT*, N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*divide)(N8ยทT*, N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*modulus)(N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*shift_left)(Extent, N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*shift_right)(Extent, N8ยทT*, N8ยทT*, N8ยทT*);
+    N8ยทStatus (*arithmetic_shift_right)(Extent, N8ยทT*, N8ยทT*);
+
+    N8ยทT* (*access)(N8ยทT*, Extent);
+    void (*from_uint32)(N8ยทT *destination ,uint32_t value);
+  } N8ยทM;
+
+  Local const N8ยทM N8ยทm; // initialized in the LOCAL section
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef N8ยทIMPLEMENTATION
+
+  // this part goes into the library
+  #ifndef LOCAL
+
+  #include <stdarg.h>
+  #include <stdlib.h>
+
+  struct N8ยทT{
+    Digit d0;
+  };
+
+  N8ยทT N8ยทconstant[4] = {
+  {.d0 = 0},
+  {.d0 = 1},
+  {.d0 = ~(uint8_t)0},
+  {.d0 = 1 << 7}
+  };
+
+  N8ยทT *N8ยทzero = &N8ยทconstant[0];
+  N8ยทT *N8ยทone = &N8ยทconstant[1];
+  N8ยทT *N8ยทall_one_bit = &N8ยทconstant[2];
+  N8ยทT *N8ยทmsb = &N8ยทconstant[3];
+  N8ยทT *N8ยทlsb = &N8ยทconstant[1];
+
+  // the allocate an array of N8
+  N8ยทT *N8ยทallocate_array(Extent extent ,N8ยทAllocate_MemoryFault memory_fault){
+    N8ยทT *instance = malloc((extent + 1) * sizeof(N8ยทT));
+    if(!instance){
+      return memory_fault ? memory_fault(extent) : NULL;
+    }
+    return instance;
+  }
+
+  N8ยทT *N8ยทallocate_array_zero(Extent extent ,N8ยทAllocate_MemoryFault memory_fault){
+    N8ยทT *instance = calloc(extent + 1, sizeof(N8ยทT));
+    if(!instance){
+      return memory_fault ? memory_fault(extent) : NULL;
+    }
+    return instance;
+  }
+
+  void N8ยทdeallocate(N8ยทT *unencumbered){
+    free(unencumbered);
+  }
+
+
+  #endif
+
+  // This part is included after the library user's code
+  #ifdef LOCAL
+
+    // instance
+
+    struct N8ยทT{
+      Digit d0;
+    };
+
+    // temporary variables
+    Local N8ยทT N8ยทt[4];
+
+    // allocation 
+
+    extern N8ยทT *N8ยทallocate_array(Extent, N8ยทAllocate_MemoryFault);
+    extern N8ยทT *N8ยทallocate_array_zero(Extent, N8ยทAllocate_MemoryFault);
+    extern void N8ยทdeallocate(N8ยทT *);
+
+    // so the user can access numbers in an array allocation
+    Local N8ยทT* N8ยทaccess(N8ยทT *array ,Extent index){
+      return &array[index];
+    }
+
+    Local void N8ยทfrom_uint32(N8ยทT *destination ,uint32_t value){
+      if(destination == NULL) return;
+      destination->d0 = (uint8_t)(value & 0xFF);
+    }
+
+    // copy, convenience copy
+
+    Local void N8ยทcopy(N8ยทT *destination ,N8ยทT *source){
+      if(source == destination) return;
+      *destination = *source;
+    }
+
+    Local void N8ยทset_to_zero(N8ยทT *instance){
+      instance->d0 = 0;
+    }
+
+    Local void N8ยทset_to_one(N8ยทT *instance){
+      instance->d0 = 1;
+    }
+
+    // bit operations
+
+    Local void N8ยทbit_and(N8ยทT *result, N8ยทT *a, N8ยทT *b){
+      result->d0 = a->d0 & b->d0;
+    }
+
+    Local void N8ยทbit_or(N8ยทT *result, N8ยทT *a, N8ยทT *b){
+      result->d0 = a->d0 | b->d0;
+    }
+
+    Local void N8ยทbit_complement(N8ยทT *result, N8ยทT *a){
+      result->d0 = ~a->d0;
+    }
+
+    Local void N8ยทbit_twos_complement(N8ยทT *result ,N8ยทT *a){
+      result->d0 = (uint8_t)(~a->d0 + 1);
+    }
+
+    // test functions
+
+    Local N8ยทOrder N8ยทcompare(N8ยทT *a, N8ยทT *b){
+      if(a->d0 < b->d0) return N8ยทOrder_lt;
+      if(a->d0 > b->d0) return N8ยทOrder_gt;
+      return N8ยทOrder_eq;
+    }
+
+    Local bool N8ยทlt(N8ยทT *a ,N8ยทT *b){
+      return a->d0 < b->d0;
+    }    
+
+    Local bool N8ยทgt(N8ยทT *a ,N8ยทT *b){
+      return a->d0 > b->d0;
+    }    
+
+    Local bool N8ยทeq(N8ยทT *a ,N8ยทT *b){
+      return a->d0 == b->d0;
+    }    
+
+    Local bool N8ยทeq_zero(N8ยทT *a){
+      return a->d0 == 0;
+    }    
+
+    // arithmetic operations
+
+    Local N8ยทStatus N8ยทaccumulate(N8ยทT *accumulator1 ,N8ยทT *accumulator0 ,...){
+
+      va_list args;
+      va_start(args ,accumulator0);
+      uint32_t sum = accumulator0->d0;
+      uint32_t carry = 0;
+      N8ยทT *current;
+
+      while( (current = va_arg(args ,N8ยทT*)) ){
+        sum += current->d0;
+        if(sum < current->d0){
+          (carry)++;
+          if(carry == 0){
+            va_end(args);
+            return N8ยทStatusยทaccumulator1_overflow;
+          }
+        }
+      }
+      va_end(args);
+
+      accumulator1->d0 = (uint8_t)carry;
+      return N8ยทStatusยทok;
+    }
+
+    Local N8ยทStatus N8ยทadd(N8ยทT *sum ,N8ยทT *a ,N8ยทT *b){
+      uint32_t result = (uint32_t)a->d0 + (uint32_t)b->d0;
+      sum->d0 = (uint8_t)(result & 0xFF);
+      return (result >> 8) ? N8ยทStatusยทcarry : N8ยทStatusยทok;
+    }
+
+    Local bool N8ยทincrement(N8ยทT *a){
+      a->d0++;
+      return (a->d0 == 0);
+    }
+
+    Local N8ยทStatus N8ยทsubtract(N8ยทT *difference ,N8ยทT *a ,N8ยทT *b){
+      uint32_t diff = (uint32_t)a->d0 - (uint32_t)b->d0;
+      difference->d0 = (uint8_t)(diff & 0xFF);
+      return (diff > a->d0) ? N8ยทStatusยทborrow : N8ยทStatusยทok;
+    }
+
+    Local N8ยทStatus N8ยทmultiply(N8ยทT *product1 ,N8ยทT *product0 ,N8ยทT *a ,N8ยทT *b){
+      uint32_t product = (uint32_t)a->d0 * (uint32_t)b->d0;
+      product0->d0 = (uint8_t)(product & 0xFF);
+      product1->d0 = (uint8_t)((product >> 8) & 0xFF);
+
+      if(product1->d0 == 0) return N8ยทStatusยทone_word_product;
+      return N8ยทStatusยทtwo_word_product;
+    }
+
+    Local N8ยทStatus N8ยทdivide(N8ยทT *remainder ,N8ยทT *quotient ,N8ยทT *a ,N8ยทT *b){
+      if(b->d0 == 0) return N8ยทStatusยทundefined_divide_by_zero;
+
+      uint32_t dividend = a->d0;
+      uint32_t divisor = b->d0;
+      quotient->d0 = (uint8_t)(dividend / divisor);
+      remainder->d0 = (uint8_t)(dividend - (quotient->d0 * divisor));
+
+      return N8ยทStatusยทok;
+    }
+
+    Local N8ยทStatus N8ยทmodulus(N8ยทT *remainder ,N8ยทT *a ,N8ยทT *b){
+      if(b->d0 == 0) return N8ยทStatusยทundefined_modulus_zero;
+      uint32_t dividend = a->d0;
+      uint32_t divisor = b->d0;
+      uint32_t q = dividend / divisor;
+      remainder->d0 = (uint8_t)(dividend - (q * divisor));
+      return N8ยทStatusยทok;
+    }
+
+    // bit motion
+
+    typedef uint8_t (*ShiftOp)(uint8_t, uint8_t);
+
+    Local uint8_t shift_left_op(uint8_t value, uint8_t amount){
+      return (uint8_t)(value << amount);
+    }
+
+    Local uint8_t shift_right_op(uint8_t value, uint8_t amount){
+      return (uint8_t)(value >> amount);
+    }
+
+    Local N8ยทStatus N8ยทshift
+    (
+     uint8_t shift_count
+     ,N8ยทT *spill
+     ,N8ยทT *operand
+     ,N8ยทT *fill
+     ,ShiftOp shift_op
+     ,ShiftOp complement_shift_op
+    ){
+
+      if(operand == NULL && spill == NULL) return N8ยทStatusยทok;
+
+      if(operand == NULL){
+        operand = &N8ยทt[0];
+        N8ยทcopy(operand, N8ยทzero);
+      }
+
+      if(shift_count > 7) return N8ยทStatusยทgt_max_shift_count;
+
+      N8ยทT *given_operand = &N8ยทt[1];
+      N8ยทcopy(given_operand, operand);
+
+      operand->d0 = shift_op(given_operand->d0, shift_count);
+      if(fill != NULL){
+        fill->d0 = complement_shift_op(fill->d0, (8 - shift_count));
+        N8ยทbit_or(operand, operand, fill);
+      }
+      if(spill != NULL){
+        spill->d0 = shift_op(spill->d0, shift_count);
+        spill->d0 += complement_shift_op(given_operand->d0, (8 - shift_count));
+      }
+
+      return N8ยทStatusยทok;
+    }
+
+    Local N8ยทStatus 
+    N8ยทshift_left(uint8_t shift_count, N8ยทT *spill, N8ยทT *operand, N8ยทT *fill){
+      return N8ยทshift(shift_count, spill, operand, fill, shift_left_op, shift_right_op);
+    }
+
+    Local N8ยทStatus 
+    N8ยทshift_right(uint8_t shift_count, N8ยทT *spill, N8ยทT *operand, N8ยทT *fill){
+      return N8ยทshift(shift_count, spill, operand, fill, shift_right_op, shift_left_op);
+    }
+
+    Local N8ยทStatus 
+    N8ยทarithmetic_shift_right(uint8_t shift_count, N8ยทT *operand, N8ยทT *spill){
+
+      if(shift_count > 7) return N8ยทStatusยทgt_max_shift_count;
+
+      if(operand == NULL){
+        operand = &N8ยทt[0];
+        N8ยทcopy(operand, N8ยทzero);
+      }
+
+      N8ยทT *fill = (operand->d0 & 0x80) ? N8ยทall_one_bit : N8ยทzero;
+      return N8ยทshift_right(shift_count, spill, operand, fill);
+    }
+
+    Local const N8ยทM N8ยทm = {
+
+      .allocate_array = N8ยทallocate_array
+     ,.allocate_array_zero = N8ยทallocate_array_zero
+     ,.deallocate = N8ยทdeallocate
+
+     ,.copy = N8ยทcopy
+     ,.bit_and = N8ยทbit_and
+     ,.bit_or = N8ยทbit_or
+     ,.bit_complement = N8ยทbit_complement
+     ,.bit_twos_complement = N8ยทbit_twos_complement
+     ,.compare = N8ยทcompare
+     ,.lt = N8ยทlt
+     ,.gt = N8ยทgt
+     ,.eq = N8ยทeq
+     ,.eq_zero = N8ยทeq_zero
+     ,.accumulate = N8ยทaccumulate
+     ,.add = N8ยทadd
+     ,.increment = N8ยทincrement
+     ,.subtract = N8ยทsubtract
+     ,.multiply = N8ยทmultiply
+     ,.divide = N8ยทdivide
+     ,.modulus = N8ยทmodulus
+     ,.shift_left = N8ยทshift_left
+     ,.shift_right = N8ยทshift_right
+     ,.arithmetic_shift_right = N8ยทarithmetic_shift_right
+
+     ,.access = N8ยทaccess
+     ,.from_uint32 = N8ยทfrom_uint32
+    };
+
+  #endif
+
+#endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/TM_scratch.c b/developer/deprecated๐Ÿ–‰/2025-03-29/TM_scratch.c
new file mode 100644 (file)
index 0000000..13b2240
--- /dev/null
@@ -0,0 +1,65 @@
+      // This initializes 'inner'.
+      // `alignment` is an extent, e.g. extent_ofยทAU(uint64_t) = 0x7
+      Local TMยทStatus ฮž(TMยทNX ,CVT)ยทlargest_aligned(
+        TMยทNXยทAU *outer ,ฮž(TMยทNX ,CVT) *inner ,extentยทAU alignment
+      ){
+        uintptr_t p0 = (uintptr_t)outer->position;
+        uintptr_t p1 = (uintptr_t)outer->position + outer->extent;
+
+        CVT *p0_aligned = (CVT *)(
+          (p0 + alignment) & ~( (uintptr_t)alignment )
+        );
+        CVT *p1_aligned = (CVT *)(
+          ( p1 - extent_ofยทAU(CVT) ) & ~( (uintptr_t)alignment )
+        );
+
+        if( p1_aligned < p0_aligned ) return TMยทStatusยทderailed;
+
+        inner->position = p0_aligned;
+        inner->extent = (ฮž(extent_t ,CVT))(p1_aligned - p0_aligned};
+        return TMยทStatusยทon_track;
+      }
+
+
+
+    
+      Local TMยทStatus TMยทNXยทtopo(TMยทNX *tm ,TMยทTapeยทTopo *topo){
+        #ifdef TMยทDebug
+          TMยทGuardยทinit_count(chk);
+          TMยทGuardยทfg.check(&chk ,1 ,tm ,TMยทNX_##CVTยทMsgยทtm);
+          TMยทGuardยทfg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
+          TMยทGuardยทif_return(chk);
+        #endif
+        if(tm->extentยทAU == 0){
+          *topo = TMยทTapeยทTopoยทsingleton; 
+        }else{
+          *topo = TMยทTapeยทTopoยทsegment;
+        }
+        return TMยทStatusยทon_track;
+      }
+
+      // extentยทAU is an AU index
+      Local TMยทStatus TMยทNXยทextentยทAU(TMยทNX *tm ,extentยทAU *extentยทAU){
+        TMยทTapeยทTopo topo;
+        TMยทStatus status = TMยทNX_##CVTยทtopo(tm ,&topo);
+        boolean good_topo = 
+          (status == TMยทStatusยทon_track) && (topo & TMยทTapeยทTopoยทfinite_nz)
+          ;
+
+        #ifdef TMยทDebug
+          TMยทGuardยทinit_count(chk);
+          TMยทGuardยทfg.check(&chk ,1 ,tm ,TMยทNXยทMsgยทtm);
+          TMยทGuardยทfg.check(&chk ,1 ,extentยทAU ,TMยทNXยทMsgยทextentยทAU);
+          TMยทGuardยทfg.check(
+            &chk ,0 ,good_topo
+            ,"Tape does not exist or topology does not have an extentยทAU."
+          );
+          TMยทGuardยทif_return(chk);
+        #endif
+
+        if(!good_topo) return TMยทStatusยทderailed;
+        *extentยทAU = tm->array.extentยทAU;
+        return TMยทStatusยทon_track;
+      }
+
+    #endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/environment.h b/developer/deprecated๐Ÿ–‰/2025-03-29/environment.h
new file mode 100644 (file)
index 0000000..cdea83c
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef MpblockยทENVIRONMENT_H
+#define MpblockยทENVIRONMENT_H
+
+
+#endif
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/test_setup.cli.c b/developer/deprecated๐Ÿ–‰/2025-03-29/test_setup.cli.c
new file mode 100644 (file)
index 0000000..f1c6e68
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+
+  A placeholder to see if make etc. is working.
+
+*/
+
+#define IFACE
+#include <stdio.h>
+#include <stdlib.h>
+
+// No need to define IMPLEMENTATION as `main` is one and done.
+
+int main(int argc ,char *argv[] ,char *envp[]){
+  if(argc != 1){
+    fprintf(stderr, "Usage: %s\n", argv[0]);
+    return EXIT_FAILURE;
+  }
+
+  fprintf(stderr, "%s done\n", argv[0]);
+
+  return 0;
+}
diff --git a/developer/deprecated๐Ÿ–‰/2025-03-29/update.lib.c b/developer/deprecated๐Ÿ–‰/2025-03-29/update.lib.c
new file mode 100644 (file)
index 0000000..61c5cf4
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+  Copy - Memory copy operations with attention to alignment.
+  Provides optimized copy and byte order reversal functions.
+*/
+
+#define CopyยทDEBUG
+
+#ifndef FACE
+#define CopyยทIMPLEMENTATION
+#define FACE
+#endif 
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef CopyยทFACE
+#define CopyยทFACE
+
+  #include <stdint.h>
+  #include <stddef.h>
+
+  typedef struct{
+    void *read0 
+    ,size_t read_size
+    ,void *write0
+    ,size_t write_size;
+  } Copyยทit;
+
+  typedef enum{
+     CopyยทStatusยทperfect_fit = 0
+    ,CopyยทStatusยทargument_guard
+    ,CopyยทStatusยทread_surplus
+    ,CopyยทStatusยทread_surplus_write_gap
+    ,CopyยทStatusยทwrite_available
+    ,CopyยทStatusยทwrite_gap;
+  } CopyยทStatus;
+
+  typedef enum{
+    CopyยทWFItยทModeยทnone = 0
+    ,CopyยทWFItยทModeยทbytes
+    ,CopyยทWFItยทModeยทbytes_reverse
+    ,CopyยทWFItยทModeยทwrite_hex
+    ,CopyยทWFItยทModeยทread_hex;
+  } CopyยทWFItยทMode;
+
+  typedef enum{
+    CopyยทWFItยทStatusยทvalid = 0
+    ,CopyยทWFItยทStatusยทnull_read
+    ,CopyยทWFItยทStatusยทnull_write
+    ,CopyยทWFItยทStatusยทzero_buffer
+    ,CopyยทWFItยทStatusยทoverlap
+    ,CopyยทWFItยทStatusยทwrite_too_small;
+  } CopyยทWFItยทStatus;
+
+  typedef struct{
+    void *region( void *read0 ,void *read1 ,void *write0 )
+    ,void *reverse_byte_order( void *read0 ,void *read1 ,void *write0 );
+  } CopyยทM;
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef CopyยทIMPLEMENTATION
+
+  // this part goes into Nlib.a
+  #ifndef LOCAL
+  #endif 
+
+  #ifdef LOCAL
+
+    Local CopyยทWFItยทStatus Copyยทwellformed_it(Copyยทit *it){
+      char *this_name = "Copyยทwellformed_it";
+      CopyยทWFItยทStatus status = CopyยทWFItยทStatusยทvalid;
+
+      if(it->read0 == NULL){
+        fprintf( stderr ,"%s: NULL read pointer\n" ,this_name );
+        status |= CopyยทWFItยทStatusยทnull_read;
+      }
+
+      if(it->write0 == NULL){
+        fprintf( stderr ,"%s: NULL write pointer\n" ,this_name );
+        status |= CopyยทWFItยทStatusยทnull_write;
+      }
+
+      if(it->read_size == 0){
+        fprintf( stderr ,"%s: Zero-sized read buffer\n" ,this_name );
+        status |= CopyยทWFItยทStatusยทzero_read_buffer;
+      }
+
+      if(it->write_size == 0){
+        fprintf( stderr ,"%s: Zero-sized write buffer\n" ,this_name );
+        status |= CopyยทWFItยทStatusยทzero_write_buffer;
+      }
+
+      if( Copyยทoverlap_size_interval(it->read0 ,it->read_size ,it->write0 ,it->write_size) ){
+        fprintf( stderr ,"%s: Read and write buffers overlap!\n" ,this_name );
+        status |= CopyยทWFItยทStatusยทoverlap;
+      }
+
+      return status;
+    }
+
+  #endif // LOCAL
+
+#endif // IMPLEMENTATION
index ba92ca2..b320ac4 100644 (file)
 
    In a call, space is allowed between the macro name and the argument list.
 
+   Not in strings, not embedded in other tokens. If a macro definition has the same name as the call, then that is a redefinition, an redefinition is not allowed.
+
+   cpp scans the tokens in the translation unit, upon finding a macro call it replaces it with the body from the macro definition using the following steps:
+
 ** 1. Argument Substitution Phase
 
    When the macro is invoked:
diff --git a/developer/example/0_readme.org b/developer/example/0_readme.org
new file mode 100644 (file)
index 0000000..d8f8a7d
--- /dev/null
@@ -0,0 +1,3 @@
+
+To build these standalone edit the tool๐Ÿ–‰/makefil and uncommon the SRC=example and the CEFLAGS+= -I/cpp๐Ÿ–‰  lines.  Then do the usual make clean dependency; make cli
+
diff --git a/developer/example/bespoke_type.cli.c b/developer/example/bespoke_type.cli.c
new file mode 100644 (file)
index 0000000..b8de24b
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+  This will print at compile time as:
+
+    example/custom_type.cli.c:6:9: note: โ€˜#pragma message: C -> 7โ€™
+      6 | #pragma message( STR_VAL(C) )
+        |         ^~~~~~~
+
+  Note the C->7 on the right side of the first line. That printed
+  the name of the macro, and its value. This is a 'note' not an 'error'.
+*/
+
+#include "cpp_ext.c"
+#include "Core.lib.c"
+#include "Binding.lib.c"
+
+/*
+  This defines the Bespoke type. 
+
+  Here by 'type' we mean a Tableau to FG table binding.
+*/
+
+  #define EQ__Bespoke__oo__Bespoke
+  #undef  BindingยทTYPE
+  #define BindingยทTYPE Bespoke
+  #include "../cc๐Ÿ–‰/Binding.lib.c"
+
+#if 0
+
+  // This defines the FG table type for Bespoke (aka vtable). Each instance is a different implementation of the type sharing the same interface.
+  typedef struct{
+    void (*version)(Bespoke c);
+    void (*report)(Bespoke c ,*mess);
+  }BespokeยทFG;
+
+  // This defines the Tableau, the data that is given as a first argument of each FG table entry.  
+  typedef struct{
+    void (*version)(Bespoke c);
+    void (*report)(Bespoke c ,*mess);
+  }BespokeยทTableau;
+
+  // This creates a FG table to Tableau binding type. We will use this to represent the type.
+  // The EQ pattern is required for `FIND_ITEM` to recognize the type:
+
+  // these functions will be used for making an instance of the abstract Bespoke type
+  void Bespokeยทversion(Bespoke c){ printf("A Bespoke instance") };
+  void Bespokeยทreport(Bespoke c ,*mess){ printf("A Bespoke instance says %s" ,mess)};
+
+#endif
+
+int main(){
+  printf("running example binding.cli.c on %s at %s\n", __DATE__, __TIME__);
+
+  #define A 5
+  SHOW(A);
+
+  #define B ฮž(X,Y)
+  SHOW(B);
+
+#if 0
+  BespokeยทFG = {
+     .version = Bespokeยทversion
+    ,.report = Bespokeยทreport
+  };
+#endif
+
+  
+  return 0;
+}
+
+#define IMPLEMENTATION
+#define LOCAL
+
+//#include "../cc๐Ÿ–‰/Core.lib.c"
+//#include "../cc๐Ÿ–‰/Binding.lib.c"
diff --git a/developer/example/cpp_ext_0.c b/developer/example/cpp_ext_0.c
deleted file mode 100644 (file)
index 573c27c..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
-  See also 
-    https://github.com/18sg/uSHET/blob/master/lib/cpp_magic.h 
-    and tutorial at: http://jhnet.co.uk/articles/cpp_magic
-
-    documents in $REPO_HOME/developer/document๐Ÿ–‰
-
-1. Provides:
-
-  Raw constants: ZERO, ONE, COMMA, SEMICOLON
-
-  Token tagging: _TWION_0, _TWION_1
-
-  Controlled concatenation: CAT2, CAT3, CAT4
-
-  Existence (now EXISTS) with token safety via ##
-
-  Rewrite matchers: MATCH_RWR, NOT_MATCH_RWR
-
-  Logical base: _AND, _OR, _NOT, BOOL, EQ, NOT_EQ
-
-  Structural access: FIRST, REST, SECOND, THIRD
-
-  Branching: IF_ELSE(...), with macro-safe conditioning
-
-  Tests for all major features: try_eq.c, try_access.c, try_3_if.c, etc.
-
-2.
-  These are the non-recursive extensions.  See cpp_ext_1 for the recursive extensions.
- 
-3.
-  The 'twion' is cute. It is reminiscent of a complex number in math. Like the complex number that is fed into scalar equestions.  The twion is a pair given to functions that only take singletons.
-
-4.
-  0 is false
-  1 is true
-
-  Macros starting with an '_' (underscore) are private.
-
-  EQ comparisons apart from logic comparisons, must be registered in advance. They take the form of, EQ__<x>__oo__<y>, note comments below.
-
-5. todo
-
-cpp_ext as separate project
-make the try into tests
-make EXISTS true, leave an empty element as false
-
-IS_LIST to distinguish element from list, though it will be tough to
-detect IS_LIST on a list with NOT_EXISTS elements,  then a list with all
-empty elements is still a list, still exits.
-
-mv BOOL AND OR 
-make AND and OR versions of FIND on EXISTS  (existence quantification)
-
-find a better name for NULL_FN
-
-*/
-
-#ifndef CPP_EXT_0
-#define CPP_EXT_0
-
-/*===========================================================================
-DEBUG
-===========================================================================*/
-
-#include <stdio.h>
-#define DEBUG_CPP
-#define STR(...) #__VA_ARGS__
-
-// print the macro and the evaluation of the macro
-#define SHOW(expr) printf("%s -> %s\n", #expr, STR(expr))
-
-/*===========================================================================
-Constants
-===========================================================================*/
-
-#define COMMA ,
-#define SEMICOLON ;
-
-#define FALSE 0
-#define TRUE  1
-
-//---------
-
-#define _TWION_0 ~,0
-#define _TWION_1 ~,1
-
-// RWR == rewrite rule, RWR_ is followed by macro name it is used in `_<name>_`
-// Matching text is replaced with nothing, making it empty
-// Potential for aliasing if x or y values have '__oo__' embedded in them.
-#define _RWR_NOT__0 
-#define _RWR_AND__1__oo__1
-#define _RWR_OR__0__oo__0
-
-// add more of this form to register other equivalences
-#define EQ__0__oo__0
-#define EQ__1__oo__1
-
-/*===========================================================================
-Primitive Concatenation
-  Not due to elegance, as `##` is convenient, rather this is 
-  used to force evaluation of arguments before `##`.
-  There will be a recursive CAT of n things in cpp_ext_1.c
-===========================================================================*/
-
-#define _CAT2(a ,b) a ## b
-#define CAT2(a ,b) _CAT2(a ,b)
-
-#define _CAT3(a ,b ,c) a ## b ## c
-#define CAT3(a ,b ,c) _CAT3(a ,b ,c)
-
-#define _CAT4(a ,b ,c ,d) a ## b ## c ## d
-#define CAT4(a ,b ,c ,d) _CAT4(a ,b ,c ,d)
-
-#define APPEND(list ,...) list ,__VA_ARGS__
-
-
-
-/*===========================================================================
-Existence
-===========================================================================*/
-
-  //----------------------------------------
-  // primitive access
-
-  // note: _FIRST of nothing, _FIRST(), means passing an empty_item as the first item
-  // so it will return empty.
-  #define _FIRST(a ,...) a
-  #define _SECOND(a ,b ,...) b
-
-  //----------------------------------------
-  // existence
-  //
-  // `##` prevents rewrite of _TWION_ in the _EXISTS_ITEM_1 macro, don't
-  // replace that with CAT!
-
-  #define _EXISTS_ITEM_2(x_item) _SECOND(x_item ,1) 
-  #define _EXISTS_ITEM_1(x_item) _EXISTS_ITEM_2(_TWION_0##x_item)
-
-  #define EXISTS_ITEM(x_item)   _EXISTS_ITEM_1(x_item)
-  #define EXISTS(...) EXISTS_ITEM( _FIRST(__VA_ARGS__) )
-
-  #define _NOT_EXISTS_ITEM_2(x_item) _SECOND(x_item ,0) 
-  #define _NOT_EXISTS_ITEM_1(x_item) _NOT_EXISTS_ITEM_2(_TWION_1##x_item)
-
-  #define NOT_EXISTS_ITEM(x_item)   _NOT_EXISTS_ITEM_1(x_item)
-  #define NOT_EXISTS(...) NOT_EXISTS_ITEM( _FIRST(__VA_ARGS__) )
-
-  // useful to use with rewrite rules that substitute to nothing
-  #define MATCH_RWR(x_item) NOT_EXISTS(x_item)
-  #define NOT_MATCH_RWR(x_item) EXISTS(x_item)
-
-/*===========================================================================
-Logic Connectors
-===========================================================================*/
-
-  #define _NOT(x_item) \
-    MATCH_RWR( CAT2(_RWR_NOT__ ,x_item) )
-
-  #define _AND(x_item ,y_item) \
-    MATCH_RWR( CAT4(_RWR_AND__ ,x_item ,__oo__ ,y_item) )
-
-  #define _OR(x_item ,y_item) \
-    NOT_MATCH_RWR( CAT4(_RWR_OR__ ,x_item ,__oo__ ,y_item) )
-
-  #define _BOOL(x_item) \
-    _AND( \
-       EXISTS_ITEM( x_item ) \
-      ,NOT_MATCH_RWR( CAT2(EQ__0__oo__ ,x_item) )  \
-    )
-  #define BOOL(x_item) _BOOL(_FIRST(x_item))
-  
-  #define NOT(x_item)         _NOT(BOOL(x_item))
-  #define AND(x_item ,y_item) _AND(BOOL(x_item) ,BOOL(y_item))
-  #define  OR(x_item ,y_item)  _OR(BOOL(x_item) ,BOOL(y_item))
-
-/*===========================================================================
-  Equality
-
-  more general than a connector because more rules can be added.
-
-  each registered equality rule has the form
-     EQ__<x>__oo__<y>
-  for example, logic equalities are already registered:
-     EQ__0__oo__0
-     EQ__1__oo__1
-
-===========================================================================*/
-
-  #define EQ(x_item ,y_item) \
-        MATCH_RWR( CAT4(EQ__ ,x_item ,__oo__ ,y_item) )
-
-  #define NOT_EQ(x_item ,y_item) \
-    NOT_MATCH_RWR( CAT4(EQ__ ,x_item ,__oo__ ,y_item) )
-
-/*===========================================================================
-  IF-ELSE construct.
-  Usage: IF_ELSE(condition)(<true case>)(<false case>)
-
-  A most amazing little macro. It has no dependencies on the other macros
-  in this file, though many will be useful for setting (condition)
-
-  The seemingly extra layer prevents BOOL_(condition) from being pasted with a ## which, if done, would prevent it from being evaluated.  Recall, the first step in evaluation is a literal copy in of the arguments.  ===symbol ========================================================================*/
-
-  #define IF(predicate)  CAT2(_IF_ ,BOOL(predicate))
-  #define _IF_1(...)          __VA_ARGS__ _IF_1_ELSE
-  #define _IF_0(...)                      _IF_0_ELSE
-  #define _IF_1_ELSE(...)
-  #define _IF_0_ELSE(...)      __VA_ARGS__
-
-/*===========================================================================
-Access
-    see ext_1 with recursion for `Nth`
-
-===========================================================================*/
-
-  // _FIRST defined in the logic section
-  #define FIRST(pad ,...)\
-    IF \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
-      (pad)                       \
-      ( _FIRST(__VA_ARGS__) )  
-
-  #define _REST(a ,...) __VA_ARGS__
-  #define REST(...)\
-    IF \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
-      ()                          \
-      ( _REST(__VA_ARGS__) )  
-
-  // _SECOND defined in the logic section
-  #define SECOND(pad ,...) \
-    IF \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
-      (pad)                       \
-      ( _SECOND(__VA_ARGS__ ,pad) )  
-
-  #define _THIRD(a ,b ,c ,...) c
-  #define THIRD(pad ,...) \
-    IF \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
-      (pad)                       \
-      ( _THIRD(__VA_ARGS__ ,pad, pad) )  
-
-#endif
diff --git a/developer/example/cpp_ext_1.c b/developer/example/cpp_ext_1.c
deleted file mode 100644 (file)
index bc241d7..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-These are the recursive extension.
-
-Simple errors can lead to very long error outputs, which might be why
-the cpp designers had obviously intended that recursion would not be possible.
-
-To be added:
-
-LIST_TOO_LONG
-  
-// scanning left to right finds first that exists
-LEFTMOST_EXISTENT 
-
-// scanning left to right finds last that exits
-RIGHTMOST_EXISTENT
-
-DROP_NOT_EXISTS_ALL
-DROP_NOT_EXISTS_LEFT
-DROPE_NOT_EXISTS_RIGHT
-
-#define _CAT(sep,first,...)                              \
-
-*/
-
-#ifndef CPP_EXT_1
-#define CPP_EXT_1
-
-/*===========================================================================
-  Force extra macro expansion (the EVAL trick)
-  This chain of EVAL macros forces the preprocessor to perform many rescans,
-  which is necessary to โ€œunrollโ€ recursive macros.
-===========================================================================*/
-//#define EVAL(...)            EVAL1024(__VA_ARGS__)
-#define EVAL(...)            EVAL32(__VA_ARGS__)
-#define EVAL1024(...)        EVAL512(EVAL512(__VA_ARGS__))
-#define EVAL512(...)         EVAL256(EVAL256(__VA_ARGS__))
-#define EVAL256(...)         EVAL128(EVAL128(__VA_ARGS__))
-#define EVAL128(...)         EVAL64(EVAL64(__VA_ARGS__))
-#define EVAL64(...)          EVAL32(EVAL32(__VA_ARGS__))
-#define EVAL32(...)          EVAL16(EVAL16(__VA_ARGS__))
-#define EVAL16(...)          EVAL8(EVAL8(__VA_ARGS__))
-#define EVAL8(...)           EVAL4(EVAL4(__VA_ARGS__))
-#define EVAL4(...)           EVAL2(EVAL2(__VA_ARGS__))
-#define EVAL2(...)           EVAL1(EVAL1(__VA_ARGS__))
-#define EVAL1(...)           __VA_ARGS__
-
-/*===========================================================================
-  Defer macros: these help โ€œhideโ€ recursive calls for additional expansion passes.
-===========================================================================*/
-#define NULL_FN()
-#define DEFER1(m)            m NULL_FN()
-#define DEFER2(m)            m NULL_FN NULL_FN()()
-#define DEFER3(m)            m NULL_FN NULL_FN NULL_FN()()()
-#define DEFER4(m)            m NULL_FN NULL_FN NULL_FN NULL_FN()()()()
-
-/*===========================================================================
-  Quantifiers
-===========================================================================*/
-
-#define _FIND(predicate ,...) \
-  IF \
-    ( NOT_EXISTS(__VA_ARGS__) ) \
-    () \
-    (IF \
-      ( predicate(FIRST(__VA_ARGS__)) ) \
-      ( FIRST( ,__VA_ARGS__) )                    \
-      ( DEFER3(_FIND_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
-     )
-#define _FIND_CONFEDERATE() _FIND
-
-// number of evals required depends upon length of not found list prefix
-#define FIND(predicate ,...) EVAL( _FIND(predicate ,__VA_ARGS__) )
-
-#define _FIND_ITEM(item ,...) \
-  IF \
-    ( NOT_EXISTS(__VA_ARGS__) ) \
-    () \
-    (IF \
-      ( EQ(item ,FIRST(__VA_ARGS__)) )             \
-      ( FIRST( ,__VA_ARGS__) )                    \
-      ( DEFER3(_FIND_ITEM_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
-     )
-#define _FIND_ITEM_CONFEDERATE() _FIND_ITEM
-
-// number of evals required depends upon length of not found list prefix
-#define FIND_ITEM(predicate ,...) EVAL( _FIND_ITEM(predicate ,__VA_ARGS__) )
-
-
-
-#endif  
diff --git a/developer/example/example_A.c b/developer/example/example_A.c
deleted file mode 100644 (file)
index edc81c6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// from http://jhnet.co.uk/articles/cpp_magic
-
-#include <stdio.h>
-#define STR(x) #x
-#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
-
-#define NULL_FN()
-#define EVAL1(...) __VA_ARGS__
-
-#define A(n) I like the number n
-
-
-int main(){
-
-  printf(
-    "    I like the number 123\n"
-    "    A (123)\n"
-  );
-  SHOW(A (123));
-  SHOW(A NULL_FN() (123));
-  printf("\n");
-
-  printf(
-    "    I like the number 123\n"
-  );
-  SHOW(EVAL1(A NULL_FN() (123)));
-  printf("\n");
-
-
-   /*
-     ... The reason this works is that when CPP encounters a function-style macro, it recursively expands the macro's arguments before substituting the macro's body and expanding that. ...
-   */
-         
-};
diff --git a/developer/example/example_eval.c b/developer/example/example_eval.c
deleted file mode 100644 (file)
index e60af83..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#define STR(x) #x
-#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
-
-int main(void){
-  printf("example_eval.c\n");
-
-  #define NULL_FN()
-  #define NEGATE(x) -x
-  #define NOT_SO_FAST(x)  NEGATE NULL_FN() (x)
-  SHOW(NOT_SO_FAST(5));
-
-  #define BE(x) x
-  SHOW(BE(NOT_SO_FAST(5)))
-}
-
-/*
-  2025-03-27T04:47:02Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > gcc example_eval.c
-
-  2025-03-27T04:47:32Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > ./a.out
-  example_eval.c
-  NOT_SO_FAST(5) โ†’ NEGATE (5)
-  BE(NOT_SO_FAST(5)) โ†’ -5
-
-*/  
diff --git a/developer/example/example_grow.c b/developer/example/example_grow.c
deleted file mode 100644 (file)
index 74f3cca..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#include <stdio.h>
-#define STR(x) #x
-// no evaluation, and one pass of evaluation
-#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
-
-#define BE(...) __VA_ARGS__
-#define NULL_FN()
-
-#include <stdio.h>
-int main(void){
-  printf("example_grow.c\n");
-  printf("\n");
-
-  // case 1
-  /* 
-    GROW(7) โ†’ 17 * GROW(7)
-    GROW(GROW(5)) โ†’ 17 * GROW(17 * GROW(5))
-  */
-  #define GROW(x) 17 * GROW(x)  
-  SHOW(GROW(7));
-  SHOW(GROW(GROW(5)));
-  printf("\n");
-
-  // case 2
-  // GROW2(11) --> 19 * GROW2 (11)
-  #define GROW2(x) 19 * GROW2 NULL_FN() (x)  
-  SHOW(GROW2(11)) ;
-  printf("\n");
-
-  // case 3
-  // GROW3(13) --> 119 * 19 * GROW2 (13)
-  #define GROW3(x) BE(119 * GROW2 NULL_FN() (x))
-  SHOW(GROW3(13));
-  printf("\n");
-    
-  // case 4
-  /* 
-    `BE` placed on the outside. The idea is that evaluation will return `123 * GROW (15)` and then this will be evaluated resulting in `123 * 123 * GROW(15)`.
-
-    However, any time GROW4 literally spells out GROW4(...) inside its own expansion
-    it will leave it literally and not expand it. 
-
-    Though it is interesting that here that occurs at a higher level in the evaluation tree than the first ocurrance of the recursive call, but still it is in the tree.
-
-    GROW4(15) --> 123 * GROW4 (15)
-  */
-  #define GROW4(x) BE(123 * GROW4 NULL_FN() (x))
-  SHOW(GROW4(15));
-  printf("\n");
-
-  // case 5
-  /*
-    Substitution of the function named followed by a trampoline works.
-
-    The original expression is written in terms of a deferred CONDFEDERATE function
-    instead of in terms of a recursive call to GROW5. cpp can suspect nothing.
-
-    The result is an expression in terms of the unevaluated CONDFEDERATE function.
-
-    The CONFEDERATE function is defined to return the token GROW5. Hence in a subsequent evaluation, and there must be a subsequent evaluation for this to work,  The CONFEDERATE function will run, return GROW5 which is next to its call parenthesis, so then the
-    recursive call will run.
-
-    BE(GROW5(21)) --> 541 * 541 * CONFEDERATE () (21)
-    BE(BE(GROW5(57))) --> 541 * 541 * 541 * CONFEDERATE () (57)
-  */
-  #define GROW5(x) 541 * CONFEDERATE NULL_FN() () (x)
-  #define CONFEDERATE() GROW5
-  SHOW(BE(GROW5(21)));
-  SHOW(BE(BE(GROW5(57))));
-  printf("\n");
-
-  // case 6
-  /*
-    Once a recursively called function is marked, or 'colored' it can never be expanded, even when passed through to another variable and separately evaluation.
-   */
-  #define GROW6(x) 1029 * GROW6 NULL_FN() (x)
-  #define RESULT1 GROW6(51)
-  SHOW(RESULT1);
-  SHOW(BE(RESULT1));
-  printf("\n");
-  // RESULT1 --> 1029 * GROW6 (51)
-  // BE(RESULT1) --> 1029 * GROW6 (51)
-
-  // case 7
-  #define RESULT2 GROW6(151)
-  SHOW(RESULT2);
-  SHOW(BE(RESULT2));
-  printf("\n");
-  // RESULT2 --> 1029 * GROW6 (151)
-  // BE(RESULT2) --> 1029 * GROW6 (151)
-
-}
-/*
-  2025-03-27T10:45:39Z[developer]
-Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-> gcc example_grow.c
-
-2025-03-27T11:43:19Z[developer]
-Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-> ./a.out 
-example_grow.c
-
-GROW(7) --> 17 * GROW(7)
-GROW(GROW(5)) --> 17 * GROW(17 * GROW(5))
-
-GROW2(11) --> 19 * GROW2 (11)
-
-GROW3(13) --> 119 * 19 * GROW2 (13)
-
-GROW4(15) --> 123 * GROW4 (15)
-
-BE(GROW5(21)) --> 541 * 541 * CONFEDERATE () (21)
-BE(BE(GROW5(57))) --> 541 * 541 * 541 * CONFEDERATE () (57)
-
-RESULT1 --> 1029 * GROW6 (51)
-BE(RESULT1) --> 1029 * GROW6 (51)
-
-RESULT2 --> 1029 * GROW6 (151)
-BE(RESULT2) --> 1029 * GROW6 (151)
-
-*/
diff --git a/developer/example/example_grow2.c b/developer/example/example_grow2.c
deleted file mode 100644 (file)
index a421469..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-
-#define STR(...) #__VA_ARGS__
-// no evaluation, and one pass of evaluation
-#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
-
-#define BE(...) __VA_ARGS__
-
-#define NULL_FN() 
-#define GROW(x)     19 * _GROW NULL_FN() ()(x)
-#define _GROW() GROW
-
-
-int main(void)
-{
-    printf("One-trampoline minimal example:\n\n");
-
-    //19 * _GROW ()(7)
-    SHOW(GROW(7));
-
-    // 19 * 19 * _GROW ()(7)
-    SHOW(BE(GROW(7)));
-
-    // 19 * 19 * 19 * _GROW ()(7)
-    SHOW(BE(BE(GROW(7))));
-
-
-    return 0;
-}
diff --git a/developer/example/example_recurse.c b/developer/example/example_recurse.c
deleted file mode 100644 (file)
index 5a4b4e0..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// from http://jhnet.co.uk/articles/cpp_magic
-
-#include <stdio.h>
-
-#define STR(...) #__VA_ARGS__
-// no evaluation, and one pass of evalutation
-#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
-
-#define NULL_FN()
-
-#define EVAL32(...) EVAL16(EVAL16(__VA_ARGS__))
-#define EVAL16(...) EVAL8(EVAL8(__VA_ARGS__))
-#define EVAL8(...) EVAL4(EVAL4(__VA_ARGS__))
-#define EVAL4(...) EVAL2(EVAL2(__VA_ARGS__))
-#define EVAL2(...) EVAL1(EVAL1(__VA_ARGS__))
-#define EVAL1(...) __VA_ARGS__
-
-#define DEFER1(m) m NULL_FN()
-
-#define RECURSE() I am recursive, look: DEFER1(_RECURSE)()()
-#define _RECURSE() RECURSE
-
-
-int main(){
-
-  printf(
-    "No EVAL:\n"
-    "    RECURSE()\n"
-  );
-  SHOW(RECURSE());
-  printf("\n");
-
-  printf(
-    "With EVAL1:\n"
-    "    EVAL1(RECURSE())\n"
-  );
-  SHOW(EVAL1(RECURSE()));
-  printf("\n"); 
-
-  printf(
-    "With EVAL2:\n"
-    "    EVAL2(RECURSE())\n"
-  );
-  SHOW(EVAL2(RECURSE()));
-  printf("\n"); 
-
-  printf(
-    "With EVAL32:\n"
-    "    EVAL32(RECURSE())\n"
-  );
-  SHOW(EVAL32(RECURSE()));
-  printf("\n");
-         
-};
diff --git a/developer/example/try_1_exists.c b/developer/example/try_1_exists.c
deleted file mode 100644 (file)
index 5b52fb3..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "cpp_ext_0.c"
-
-#define F 1
-#define O1 2
-#define O2 3
-#define B 4
-#define A 5
-#define R 6
-#define D 7
-
-
-// Patch for _EXISTS to succeed on 0
-#define _REWRITE_TWION_0 _REWRITE_TWION
-
-int main(void){
-  printf("try_1_exists\n\n");
-
-  // Constant macros
-  int x COMMA y = 1;  // Tests that COMMA = ,
-  printf("y? %d\n", y);
-  printf("\n");
-
-  // Token paste test
-  int _cat_result = CAT2(CAT3(F ,O1 ,O2) ,CAT4(B ,A ,R ,D));
-  printf("FOOBARD %d\n" ,_cat_result);
-  printf("\n");
-
-  // Selector macros
-  int first = _FIRST(11 ,22 ,33);    // โ†’ 11
-  int second = _SECOND(11 ,22 ,33);  // โ†’ 22
-  printf("_FIRST(11 ,22 ,33) = %d\n", first);
-  printf("_SECOND(11 ,22 ,33) = %d\n", second);
-  printf("\n");
-
-  // Existence detection
-  int empty = EXISTS_ITEM();         // โ†’ 1 (rewrite hits)
-  int empty_0 = EXISTS_ITEM(0);      // โ†’ 1 (rewrite hits)
-  int empty_1 = EXISTS_ITEM(1);      // โ†’ 0 (no rewrite)
-  int empty_f = EXISTS_ITEM(hello);  // โ†’ 0
-
-  printf("EXISTS_ITEM() = %d\n", empty);
-  printf("EXISTS_ITEM(0) = %d\n", empty_0);
-  printf("EXISTS_ITEM(1) = %d\n", empty_1);
-  printf("EXISTS_ITEM(hello) = %d\n", empty_f);
-  printf("\n");
-
-  // Not Existence detection
-  empty = NOT_EXISTS_ITEM();         // โ†’ 1 (rewrite hits)
-  empty_0 = NOT_EXISTS_ITEM(0);      // โ†’ 1 (rewrite hits)
-  empty_1 = NOT_EXISTS_ITEM(1);      // โ†’ 0 (no rewrite)
-  empty_f = NOT_EXISTS_ITEM(hello);  // โ†’ 0
-
-  printf("NOT_EXISTS_ITEM() = %d\n", empty);
-  printf("NOT_EXISTS_ITEM(0) = %d\n", empty_0);
-  printf("NOT_EXISTS_ITEM(1) = %d\n", empty_1);
-  printf("NOT_EXISTS_ITEM(hello) = %d\n", empty_f);
-  printf("\n");
-
-
-  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
-  int empty_11 = EXISTS(10,11,12); // this is a legal call
-  int empty_12 = EXISTS(); 
-
-  // printf("EXISTS_ITEM(10,11,12) = %d\n", empty_10);
-  printf("EXISTS(10,11,12) = %d\n", empty_11);
-  printf("EXISTS() = %d\n", empty_12);
-  printf("\n");
-
-  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
-  empty_11 = NOT_EXISTS(10,11,12); // this is a legal call
-  empty_12 = NOT_EXISTS(); 
-
-  // printf("NOT_EXISTS_ITEM(10,11,12) = %d\n", empty_10);
-  printf("NOT_EXISTS(10,11,12) = %d\n", empty_11);
-  printf("NOT_EXISTS() = %d\n", empty_12);
-  printf("\n");
-
-
-  return 0;
-}
-
-/*
-  2025-03-27T12:38:04Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > gcc try_1_exists.c 
-
-  2025-03-27T12:40:32Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > ./a.out
-  _CAT(FOO ,BAR) โ†’ 12345
-
-  _FIRST(11 ,22 ,33) = 11
-  _SECOND(11 ,22 ,33) = 22
-
-  EXISTS_ITEM() = 0
-  EXISTS_ITEM(0) = 1
-  EXISTS_ITEM(1) = 1
-  EXISTS_ITEM(hello) = 1
-
-  NOT_EXISTS_ITEM() = 1
-  NOT_EXISTS_ITEM(0) = 0
-  NOT_EXISTS_ITEM(1) = 0
-  NOT_EXISTS_ITEM(hello) = 0
-
-  EXISTS(10,11,12) = 1
-  EXISTS() = 0
-
-  NOT_EXISTS(10,11,12) = 0
-  NOT_EXISTS() = 1
-*/
diff --git a/developer/example/try_2_connectors.c b/developer/example/try_2_connectors.c
deleted file mode 100644 (file)
index 1e99ee3..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-#include "cpp_ext_0.c"
-
-int main(void){
-
-  //--------------------------------------------------------------------------
-  // Existence Checks (sanity anchor)
-  //--------------------------------------------------------------------------
-
-  #define x0 
-  SHOW(  EXISTS_ITEM(x0) );       // โ†’ 0 (assumed undefined)
-  SHOW(  NOT_EXISTS_ITEM(x0) );   // โ†’ 1
-  printf("\n");
-
-  SHOW(  MATCH(x0) );
-  SHOW(  NOT_MATCH(x0) );
-  printf("\n");
-
-  //--------------------------------------------------------------------------
-  // Primitive Connectors
-  //--------------------------------------------------------------------------
-
-  SHOW( _NOT(0) );  // _RWR_NOT_0 is defined โ†’ MATCH โ†’ 1
-  SHOW( _NOT(1) );  // no rule โ†’ MATCH fails โ†’ 0
-  printf("\n");
-
-  SHOW( _AND(0 ,0) );  // rule defined โ†’ MATCH โ†’ 1
-  SHOW( _AND(1 ,0) );  // rule defined โ†’ MATCH โ†’ 1
-  SHOW( _AND(0 ,1) );  // rule defined โ†’ MATCH โ†’ 1
-  SHOW( _AND(1 ,1) );  // rule defined โ†’ MATCH โ†’ 1
-  SHOW( _AND(1 ,x) );  // not legal args, but worked, rule missing โ†’ MATCH fails โ†’ 0
-  printf("\n");
-
-  SHOW( _OR(0 ,0) );   // rule defined โ†’ NOT_MATCH โ†’ 0
-  SHOW( _OR(0 ,1) );   // rule missing โ†’ NOT_MATCH โ†’ 1
-  SHOW( _OR(1 ,0) );   // rule missing โ†’ NOT_MATCH โ†’ 1
-  SHOW( _OR(1 ,1) );   // rule missing โ†’ NOT_MATCH โ†’ 1
-  printf("\n");
-
-  //--------------------------------------------------------------------------
-  // Logical Connectors (BOOL + AND/OR/NOT)
-  //--------------------------------------------------------------------------
-
-  printf("x0 is a macro with an empty definition");
-
-  SHOW( _BOOL(0) );       // 0
-  SHOW( _BOOL(1) );       // 1
-  SHOW( _BOOL(2) );       //  1 because it exists
-  SHOW( _BOOL(x0) );       // 0 because it does not exit (see the #define at the top)
-  printf("\n");
-
-  SHOW( BOOL(0) );       // _FIRST = 0, EXISTS_ITEM(_FIRST) = 0 โ†’ _AND(0 ,1) โ†’ 0
-  SHOW( BOOL(1) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
-  SHOW( BOOL(10) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
-  SHOW( BOOL() );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
-  SHOW( BOOL(x0) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
-  printf("\n");
-
-  SHOW( NOT(0) );        // BOOL = 0 โ†’ NOT(0) = _NOT(0) = 1
-  SHOW( NOT(1) );        // BOOL = 0 โ†’ NOT(0) = 1
-  SHOW( NOT() );        // BOOL = 0 โ†’ NOT(0) = 1
-  SHOW( NOT(10) );        // BOOL = 0 โ†’ NOT(0) = 1
-  printf("\n");
-
-  SHOW( AND(1 ,0) );     // 0
-  SHOW( AND(1 ,1) );     // BOOL(1), BOOL(1) = 0,0 โ†’ AND(0 ,0) = _AND(0 ,0) = 1
-  printf("\n");
-
-  SHOW( OR(0 ,0) );      // BOOL(1), BOOL(0) = 0,0 โ†’ OR(0 ,0) = _OR(0 ,0) = 0
-  SHOW( OR(1 ,0) );      // BOOL(1), BOOL(0) = 0,0 โ†’ OR(0 ,0) = _OR(0 ,0) = 0
-  printf("\n");
-
-  //--------------------------------------------------------------------------
-  // Compound Connectors
-  //--------------------------------------------------------------------------
-
-  // Double NOT
-  SHOW( NOT(NOT(0)) );     // โ†’ NOT(1) โ†’ _NOT(1) โ†’ 0
-  SHOW( NOT(NOT(1)) );     // โ†’ NOT(0) โ†’ _NOT(0) โ†’ 1
-
-  // Triple NOT
-  SHOW( NOT(NOT(NOT(0))) );  // โ†’ NOT(0) โ†’ _NOT(0) โ†’ 1
-  SHOW( NOT(NOT(NOT(1))) );  // โ†’ NOT(1) โ†’ _NOT(1) โ†’ 0
-  printf("\n");
-
-  // Nested AND
-  SHOW( AND(1 ,AND(1 ,0)) );  // AND(1 ,AND(1 ,0)) โ†’ AND(1 ,0) โ†’ _AND(1 ,0) = 0
-  SHOW( AND(1 ,AND(1 ,1)) );  // โ†’ AND(1 ,1) โ†’ _AND(1 ,1) = 1
-  printf("\n");
-
-  // Nested OR
-  SHOW( OR(0 ,OR(0 ,1)) );    // โ†’ OR(0 ,1) โ†’ _OR(0 ,1) = 1
-  SHOW( OR(0 ,OR(0 ,0)) );    // โ†’ OR(0 ,0) โ†’ _OR(0 ,0) = 0
-  printf("\n");
-
-  // Mixed nesting
-  SHOW( AND(NOT(0) ,1) );     // โ†’ AND(1 ,1) โ†’ _AND(1 ,1) = 1
-  SHOW( AND(NOT(1) ,1) );     // โ†’ AND(0 ,1) โ†’ _AND(0 ,1) = 0
-  SHOW( OR(NOT(1) ,1) );      // โ†’ OR(0 ,1) โ†’ _OR(0 ,1) = 1
-  SHOW( OR(NOT(0) ,0) );      // โ†’ OR(1 ,0) โ†’ _OR(1 ,0) = 1
-  printf("\n");
-
-  // Deep mix
-  SHOW( NOT(AND(1 ,NOT(1))) );  // AND(1 ,0) = _AND(1 ,0) = 0 โ†’ NOT(0) = _NOT(0) = 1
-  SHOW( NOT(OR(0 ,NOT(0))) );   // OR(0 ,1) = _OR(0 ,1) = 1 โ†’ NOT(1) = _NOT(1) = 0
-  printf("\n");
-
-  // Asymmetric nesting
-  SHOW( AND(OR(0 ,1) ,AND(1 ,1)) ); // OR(0 ,1) = 1, AND(1 ,1) = 1 โ†’ AND(1 ,1) = 1
-  SHOW( OR(AND(1 ,0) ,AND(1 ,1)) ); // AND(1 ,0) = 0, AND(1 ,1) = 1 โ†’ OR(0 ,1) = 1
-  printf("\n");
-
-  return 0;
-}
-/*
-  2025-03-27T12:59:39Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > gcc try_2_connectors.c 
-
-  2025-03-27T13:00:11Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  > ./a.out
-  EXISTS_ITEM(x0) --> 0
-  NOT_EXISTS_ITEM(x0) --> 1
-
-  MATCH(x0) --> MATCH()
-  NOT_MATCH(x0) --> NOT_MATCH()
-
-  _NOT(0) --> 1
-  _NOT(1) --> 0
-
-  _AND(0 ,0) --> 0
-  _AND(1 ,0) --> 0
-  _AND(0 ,1) --> 0
-  _AND(1 ,1) --> 1
-  _AND(1 ,x) --> 0
-
-  _OR(0 ,0) --> 0
-  _OR(0 ,1) --> 1
-  _OR(1 ,0) --> 1
-  _OR(1 ,1) --> 1
-
-  _EQ(0 ,0) --> 1
-  _EQ(1 ,1) --> 1
-  _EQ(0 ,1) --> 0
-  _EQ(x ,x) --> 0
-
-  _NOT_EQ(0 ,1) --> 1
-  _NOT_EQ(0 ,0) --> 0
-
-  _BOOL_2(0) --> 0
-  _BOOL_2(1) --> 1
-  _BOOL_2(2) --> 1
-  _BOOL_2(x0) --> 0
-
-  BOOL(0) --> 0
-  BOOL(1) --> 1
-  BOOL(10) --> 1
-  BOOL() --> 0
-  BOOL(x0) --> 0
-
-  NOT(0) --> 1
-  NOT(1) --> 0
-  NOT() --> 1
-  NOT(10) --> 0
-
-  AND(1 ,0) --> 0
-  AND(1 ,1) --> 1
-
-  OR(0 ,0) --> 0
-  OR(1 ,0) --> 1
-
-  NOT(NOT(0)) --> 0
-  NOT(NOT(1)) --> 1
-  NOT(NOT(NOT(0))) --> 1
-  NOT(NOT(NOT(1))) --> 0
-
-  AND(1 ,AND(1 ,0)) --> 0
-  AND(1 ,AND(1 ,1)) --> 1
-
-  OR(0 ,OR(0 ,1)) --> 1
-  OR(0 ,OR(0 ,0)) --> 0
-
-  AND(NOT(0) ,1) --> 1
-  AND(NOT(1) ,1) --> 0
-  OR(NOT(1) ,1) --> 1
-  OR(NOT(0) ,0) --> 1
-
-  NOT(AND(1 ,NOT(1))) --> 1
-  NOT(OR(0 ,NOT(0))) --> 0
-
-  AND(OR(0 ,1) ,AND(1 ,1)) --> 1
-  OR(AND(1 ,0) ,AND(1 ,1)) --> 1
-
-
-  2025-03-27T13:00:12Z[developer]
-  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
-  >
-*/
-
-  
diff --git a/developer/example/try_3_eq.c b/developer/example/try_3_eq.c
deleted file mode 100644 (file)
index 6cb8aaf..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "cpp_ext_0.c"
-
-int main(void){
-
-  //---------------------------------------------------------------------------
-  // EQ Tests โ€” identity and mismatch
-  //---------------------------------------------------------------------------
-
-  SHOW(EQ(0 ,0));      // Expected โ†’ 1
-  SHOW(EQ(1 ,1));      // Expected โ†’ 1
-  SHOW(EQ(0 ,1));      // Expected โ†’ 0
-  SHOW(EQ(1 ,0));      // Expected โ†’ 0
-
-  SHOW(EQ(x ,x));      // Expected โ†’ 0 (no _RWREQ__x__oo__x defined)
-  SHOW(EQ(x ,y));      // Expected โ†’ 0
-
-  //---------------------------------------------------------------------------
-  // NOTEQ Tests โ€” inverse behavior
-  //---------------------------------------------------------------------------
-
-  SHOW(NOT_EQ(0 ,0));  // Expected โ†’ 0 (because EQ โ†’ 1, so EXISTS โ†’ 0)
-  SHOW(NOT_EQ(1 ,1));  // Expected โ†’ 0
-  SHOW(NOT_EQ(0 ,1));  // Expected โ†’ 1
-  SHOW(NOT_EQ(1 ,0));  // Expected โ†’ 1
-
-  SHOW(NOT_EQ(x ,x));  // Expected โ†’ 1 (EQ not defined โ†’ NOTEQ = 1)
-  SHOW(NOT_EQ(x ,y));  // Expected โ†’ 1
-
-  //---------------------------------------------------------------------------
-  // Mixed cases with macros
-  //---------------------------------------------------------------------------
-
-  #define XSYM 0
-  #define YSYM 1
-
-  SHOW(EQ(XSYM ,XSYM));      // Expected โ†’ 1 (0,0)
-  SHOW(EQ(XSYM ,YSYM));      // Expected โ†’ 0 (0,1)
-  SHOW(NOT_EQ(XSYM ,YSYM));  // Expected โ†’ 1
-
-  SHOW(EQ(XSYM ,0));         // Expected โ†’ 1
-  SHOW(EQ(XSYM ,1));         // Expected โ†’ 0
-
-  SHOW(NOT_EQ(YSYM ,0));     // Expected โ†’ 1
-  SHOW(NOT_EQ(YSYM ,1));     // Expected โ†’ 0
-
-  //---------------------------------------------------------------------------
-  // Edge case: undefined symbol
-  //---------------------------------------------------------------------------
-
-  SHOW(EQ(z ,z));        // Expected โ†’ 0
-  SHOW(NOT_EQ(z ,z));    // Expected โ†’ 1
-
-  printf("\n");
-  return 0;
-}
diff --git a/developer/example/try_4_if.c b/developer/example/try_4_if.c
deleted file mode 100644 (file)
index cdb60e6..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "cpp_ext_0.c"
-
-int main(void){
-
-  //---------------------------------------------------------------------------
-  // Basic boolean cases
-  //---------------------------------------------------------------------------
-
-  SHOW(IF_ELSE(1)(yes)(no)); 
-  SHOW(IF_ELSE(0)(yes)(no));        // โ†’ no
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Symbolic identifiers
-  //---------------------------------------------------------------------------
-  SHOW(IF_ELSE(TRUE)(ok)(fail));    // โ†’ ok
-  SHOW(IF_ELSE(FALSE)(ok)(fail));   // โ†’ fail
-  SHOW(IF_ELSE(foo)(alpha)(omega)); // โ†’ omega (foo is undefined)
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Logic expressions
-  //---------------------------------------------------------------------------
-  SHOW(IF_ELSE(AND(1 ,1))(pass)(fail));  // โ†’ pass
-  SHOW(IF_ELSE(OR(0 ,0))(yes)(no));      // โ†’ no
-  SHOW(IF_ELSE(NOT(0))(on)(off));        // โ†’ on
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Code-like output
-  //---------------------------------------------------------------------------
-  SHOW(IF_ELSE(1)(int x = 1;)(int x = 2;));  // โ†’ int x = 1;
-  SHOW(IF_ELSE(0)(int x = 1;)(int x = 2;));  // โ†’ int x = 2;
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Comma usage in true/false branches
-  //---------------------------------------------------------------------------
-  SHOW(IF_ELSE(1)(a ,b ,c)(x ,y ,z));  // โ†’ a ,b ,c
-  SHOW(IF_ELSE(0)(a ,b ,c)(x ,y ,z));  // โ†’ x ,y ,z
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Empty condition
-  //---------------------------------------------------------------------------
-  SHOW(IF_ELSE()(true)(false));       // โ†’ false (BOOL() = 0)
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // Nested IF_ELSE
-  //---------------------------------------------------------------------------
-  SHOW(
-    IF_ELSE(AND(1 ,1))(
-      IF_ELSE(0)(inner_true)(inner_false)
-    )(
-      outer_false
-    )
-  ); // โ†’ inner_false
-  printf("\n");
-
-  return 0;
-}
diff --git a/developer/example/try_5_access.c b/developer/example/try_5_access.c
deleted file mode 100644 (file)
index e9db0ae..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "cpp_ext_0.c"
-
-int main(void){
-
-  //---------------------------------------------------------------------------
-  // FIRST
-  //---------------------------------------------------------------------------
-
-  SHOW(FIRST(foo));                 // โ†’ foo         (only pad, no args)
-  SHOW(FIRST(foo ,a));             // โ†’ a
-  SHOW(FIRST(foo ,a ,b ,c));       // โ†’ a
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // REST
-  //---------------------------------------------------------------------------
-
-  SHOW(REST());                    // โ†’ (empty)
-  SHOW(REST(a));                  // โ†’ (empty)
-  SHOW(REST(a ,b));               // โ†’ b
-  SHOW(REST(a ,b ,c ,d));         // โ†’ b ,c ,d
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // SECOND
-  //---------------------------------------------------------------------------
-
-  SHOW(SECOND(X));                // โ†’ X         (only pad)
-  SHOW(SECOND(X ,a));             // โ†’ X         (only one arg, fallback to pad)
-  SHOW(SECOND(X ,a ,b));          // โ†’ b
-  SHOW(SECOND(X ,a ,b ,c));       // โ†’ b
-  printf("\n");
-
-  //---------------------------------------------------------------------------
-  // THIRD
-  //---------------------------------------------------------------------------
-
-  SHOW(THIRD(X));                 // โ†’ X         (pad returned)
-  SHOW(THIRD(X ,a));              // โ†’ X
-  SHOW(THIRD(X ,a ,b));           // โ†’ X
-  SHOW(THIRD(X ,a ,b ,c));        // โ†’ c
-  SHOW(THIRD(X ,a ,b ,c ,d));     // โ†’ c
-  printf("\n");
-
-  return 0;
-}
diff --git a/developer/example/try_6_list.c b/developer/example/try_6_list.c
deleted file mode 100644 (file)
index 2bcc339..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "cpp_ext_0.c"
-#include "cpp_ext_1.c"
-
-#define LIST int ,float ,char ,void 
-
-// register equality
-#define EQ__int__oo__int
-#define EQ__float__oo__float
-#define EQ__char__oo__char
-#define EQ__void__oo__void
-
-// make predicates
-#define IS_int(x)   EQ(x ,int)
-#define IS_float(x) EQ(x ,float)
-#define IS_double(x)  EQ(x ,double)
-#define IS_char(x)  EQ(x ,char)
-#define IS_void(x)  EQ(x ,void)
-
-int main(void){
-
-#define BE(...) __VA_ARGS__
-
-  SHOW(IS_char(int));
-  SHOW(IS_char(char));
-  printf("\n");
-
-  SHOW( FIND(IS_char ,) );
-  SHOW( FIND(IS_char ,char) );  // โ†’ char
-  SHOW( FIND(IS_char ,int) );  // โ†’ 
-  printf("\n");
-
-  SHOW( FIND(IS_char ,int ,void) );  // โ†’ 
-  SHOW( FIND(IS_void ,int ,void) );  // โ†’ 
-  printf("\n");
-
-  SHOW( FIND(IS_int ,LIST) ); 
-  SHOW( FIND(IS_float ,LIST) ); 
-  SHOW( FIND(IS_double ,LIST) ); 
-  SHOW( FIND(IS_char ,LIST) ); 
-  SHOW( FIND(IS_void ,LIST) ); 
-  SHOW( FIND(IS_big ,LIST) ); 
-  printf("\n");
-
-
-  //#endif
-
-  return 0;
-}
diff --git a/developer/example_cpp/.githolder b/developer/example_cpp/.githolder
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/developer/example_cpp/0_readme.org b/developer/example_cpp/0_readme.org
new file mode 100644 (file)
index 0000000..d10769b
--- /dev/null
@@ -0,0 +1,9 @@
+These are direct built one at a time, for example:
+
+   #+BEGIN_SRC bash
+   > gcc try_6_list.c 
+   > ./a.out
+   IS_char(int) -> 0
+   IS_char(char) -> 1
+   ...
+   EOF
diff --git a/developer/example_cpp/cpp_ext_0.c b/developer/example_cpp/cpp_ext_0.c
new file mode 100644 (file)
index 0000000..573c27c
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+  See also 
+    https://github.com/18sg/uSHET/blob/master/lib/cpp_magic.h 
+    and tutorial at: http://jhnet.co.uk/articles/cpp_magic
+
+    documents in $REPO_HOME/developer/document๐Ÿ–‰
+
+1. Provides:
+
+  Raw constants: ZERO, ONE, COMMA, SEMICOLON
+
+  Token tagging: _TWION_0, _TWION_1
+
+  Controlled concatenation: CAT2, CAT3, CAT4
+
+  Existence (now EXISTS) with token safety via ##
+
+  Rewrite matchers: MATCH_RWR, NOT_MATCH_RWR
+
+  Logical base: _AND, _OR, _NOT, BOOL, EQ, NOT_EQ
+
+  Structural access: FIRST, REST, SECOND, THIRD
+
+  Branching: IF_ELSE(...), with macro-safe conditioning
+
+  Tests for all major features: try_eq.c, try_access.c, try_3_if.c, etc.
+
+2.
+  These are the non-recursive extensions.  See cpp_ext_1 for the recursive extensions.
+ 
+3.
+  The 'twion' is cute. It is reminiscent of a complex number in math. Like the complex number that is fed into scalar equestions.  The twion is a pair given to functions that only take singletons.
+
+4.
+  0 is false
+  1 is true
+
+  Macros starting with an '_' (underscore) are private.
+
+  EQ comparisons apart from logic comparisons, must be registered in advance. They take the form of, EQ__<x>__oo__<y>, note comments below.
+
+5. todo
+
+cpp_ext as separate project
+make the try into tests
+make EXISTS true, leave an empty element as false
+
+IS_LIST to distinguish element from list, though it will be tough to
+detect IS_LIST on a list with NOT_EXISTS elements,  then a list with all
+empty elements is still a list, still exits.
+
+mv BOOL AND OR 
+make AND and OR versions of FIND on EXISTS  (existence quantification)
+
+find a better name for NULL_FN
+
+*/
+
+#ifndef CPP_EXT_0
+#define CPP_EXT_0
+
+/*===========================================================================
+DEBUG
+===========================================================================*/
+
+#include <stdio.h>
+#define DEBUG_CPP
+#define STR(...) #__VA_ARGS__
+
+// print the macro and the evaluation of the macro
+#define SHOW(expr) printf("%s -> %s\n", #expr, STR(expr))
+
+/*===========================================================================
+Constants
+===========================================================================*/
+
+#define COMMA ,
+#define SEMICOLON ;
+
+#define FALSE 0
+#define TRUE  1
+
+//---------
+
+#define _TWION_0 ~,0
+#define _TWION_1 ~,1
+
+// RWR == rewrite rule, RWR_ is followed by macro name it is used in `_<name>_`
+// Matching text is replaced with nothing, making it empty
+// Potential for aliasing if x or y values have '__oo__' embedded in them.
+#define _RWR_NOT__0 
+#define _RWR_AND__1__oo__1
+#define _RWR_OR__0__oo__0
+
+// add more of this form to register other equivalences
+#define EQ__0__oo__0
+#define EQ__1__oo__1
+
+/*===========================================================================
+Primitive Concatenation
+  Not due to elegance, as `##` is convenient, rather this is 
+  used to force evaluation of arguments before `##`.
+  There will be a recursive CAT of n things in cpp_ext_1.c
+===========================================================================*/
+
+#define _CAT2(a ,b) a ## b
+#define CAT2(a ,b) _CAT2(a ,b)
+
+#define _CAT3(a ,b ,c) a ## b ## c
+#define CAT3(a ,b ,c) _CAT3(a ,b ,c)
+
+#define _CAT4(a ,b ,c ,d) a ## b ## c ## d
+#define CAT4(a ,b ,c ,d) _CAT4(a ,b ,c ,d)
+
+#define APPEND(list ,...) list ,__VA_ARGS__
+
+
+
+/*===========================================================================
+Existence
+===========================================================================*/
+
+  //----------------------------------------
+  // primitive access
+
+  // note: _FIRST of nothing, _FIRST(), means passing an empty_item as the first item
+  // so it will return empty.
+  #define _FIRST(a ,...) a
+  #define _SECOND(a ,b ,...) b
+
+  //----------------------------------------
+  // existence
+  //
+  // `##` prevents rewrite of _TWION_ in the _EXISTS_ITEM_1 macro, don't
+  // replace that with CAT!
+
+  #define _EXISTS_ITEM_2(x_item) _SECOND(x_item ,1) 
+  #define _EXISTS_ITEM_1(x_item) _EXISTS_ITEM_2(_TWION_0##x_item)
+
+  #define EXISTS_ITEM(x_item)   _EXISTS_ITEM_1(x_item)
+  #define EXISTS(...) EXISTS_ITEM( _FIRST(__VA_ARGS__) )
+
+  #define _NOT_EXISTS_ITEM_2(x_item) _SECOND(x_item ,0) 
+  #define _NOT_EXISTS_ITEM_1(x_item) _NOT_EXISTS_ITEM_2(_TWION_1##x_item)
+
+  #define NOT_EXISTS_ITEM(x_item)   _NOT_EXISTS_ITEM_1(x_item)
+  #define NOT_EXISTS(...) NOT_EXISTS_ITEM( _FIRST(__VA_ARGS__) )
+
+  // useful to use with rewrite rules that substitute to nothing
+  #define MATCH_RWR(x_item) NOT_EXISTS(x_item)
+  #define NOT_MATCH_RWR(x_item) EXISTS(x_item)
+
+/*===========================================================================
+Logic Connectors
+===========================================================================*/
+
+  #define _NOT(x_item) \
+    MATCH_RWR( CAT2(_RWR_NOT__ ,x_item) )
+
+  #define _AND(x_item ,y_item) \
+    MATCH_RWR( CAT4(_RWR_AND__ ,x_item ,__oo__ ,y_item) )
+
+  #define _OR(x_item ,y_item) \
+    NOT_MATCH_RWR( CAT4(_RWR_OR__ ,x_item ,__oo__ ,y_item) )
+
+  #define _BOOL(x_item) \
+    _AND( \
+       EXISTS_ITEM( x_item ) \
+      ,NOT_MATCH_RWR( CAT2(EQ__0__oo__ ,x_item) )  \
+    )
+  #define BOOL(x_item) _BOOL(_FIRST(x_item))
+  
+  #define NOT(x_item)         _NOT(BOOL(x_item))
+  #define AND(x_item ,y_item) _AND(BOOL(x_item) ,BOOL(y_item))
+  #define  OR(x_item ,y_item)  _OR(BOOL(x_item) ,BOOL(y_item))
+
+/*===========================================================================
+  Equality
+
+  more general than a connector because more rules can be added.
+
+  each registered equality rule has the form
+     EQ__<x>__oo__<y>
+  for example, logic equalities are already registered:
+     EQ__0__oo__0
+     EQ__1__oo__1
+
+===========================================================================*/
+
+  #define EQ(x_item ,y_item) \
+        MATCH_RWR( CAT4(EQ__ ,x_item ,__oo__ ,y_item) )
+
+  #define NOT_EQ(x_item ,y_item) \
+    NOT_MATCH_RWR( CAT4(EQ__ ,x_item ,__oo__ ,y_item) )
+
+/*===========================================================================
+  IF-ELSE construct.
+  Usage: IF_ELSE(condition)(<true case>)(<false case>)
+
+  A most amazing little macro. It has no dependencies on the other macros
+  in this file, though many will be useful for setting (condition)
+
+  The seemingly extra layer prevents BOOL_(condition) from being pasted with a ## which, if done, would prevent it from being evaluated.  Recall, the first step in evaluation is a literal copy in of the arguments.  ===symbol ========================================================================*/
+
+  #define IF(predicate)  CAT2(_IF_ ,BOOL(predicate))
+  #define _IF_1(...)          __VA_ARGS__ _IF_1_ELSE
+  #define _IF_0(...)                      _IF_0_ELSE
+  #define _IF_1_ELSE(...)
+  #define _IF_0_ELSE(...)      __VA_ARGS__
+
+/*===========================================================================
+Access
+    see ext_1 with recursion for `Nth`
+
+===========================================================================*/
+
+  // _FIRST defined in the logic section
+  #define FIRST(pad ,...)\
+    IF \
+      ( NOT_EXISTS(__VA_ARGS__) ) \
+      (pad)                       \
+      ( _FIRST(__VA_ARGS__) )  
+
+  #define _REST(a ,...) __VA_ARGS__
+  #define REST(...)\
+    IF \
+      ( NOT_EXISTS(__VA_ARGS__) ) \
+      ()                          \
+      ( _REST(__VA_ARGS__) )  
+
+  // _SECOND defined in the logic section
+  #define SECOND(pad ,...) \
+    IF \
+      ( NOT_EXISTS(__VA_ARGS__) ) \
+      (pad)                       \
+      ( _SECOND(__VA_ARGS__ ,pad) )  
+
+  #define _THIRD(a ,b ,c ,...) c
+  #define THIRD(pad ,...) \
+    IF \
+      ( NOT_EXISTS(__VA_ARGS__) ) \
+      (pad)                       \
+      ( _THIRD(__VA_ARGS__ ,pad, pad) )  
+
+#endif
diff --git a/developer/example_cpp/cpp_ext_1.c b/developer/example_cpp/cpp_ext_1.c
new file mode 100644 (file)
index 0000000..bc241d7
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+These are the recursive extension.
+
+Simple errors can lead to very long error outputs, which might be why
+the cpp designers had obviously intended that recursion would not be possible.
+
+To be added:
+
+LIST_TOO_LONG
+  
+// scanning left to right finds first that exists
+LEFTMOST_EXISTENT 
+
+// scanning left to right finds last that exits
+RIGHTMOST_EXISTENT
+
+DROP_NOT_EXISTS_ALL
+DROP_NOT_EXISTS_LEFT
+DROPE_NOT_EXISTS_RIGHT
+
+#define _CAT(sep,first,...)                              \
+
+*/
+
+#ifndef CPP_EXT_1
+#define CPP_EXT_1
+
+/*===========================================================================
+  Force extra macro expansion (the EVAL trick)
+  This chain of EVAL macros forces the preprocessor to perform many rescans,
+  which is necessary to โ€œunrollโ€ recursive macros.
+===========================================================================*/
+//#define EVAL(...)            EVAL1024(__VA_ARGS__)
+#define EVAL(...)            EVAL32(__VA_ARGS__)
+#define EVAL1024(...)        EVAL512(EVAL512(__VA_ARGS__))
+#define EVAL512(...)         EVAL256(EVAL256(__VA_ARGS__))
+#define EVAL256(...)         EVAL128(EVAL128(__VA_ARGS__))
+#define EVAL128(...)         EVAL64(EVAL64(__VA_ARGS__))
+#define EVAL64(...)          EVAL32(EVAL32(__VA_ARGS__))
+#define EVAL32(...)          EVAL16(EVAL16(__VA_ARGS__))
+#define EVAL16(...)          EVAL8(EVAL8(__VA_ARGS__))
+#define EVAL8(...)           EVAL4(EVAL4(__VA_ARGS__))
+#define EVAL4(...)           EVAL2(EVAL2(__VA_ARGS__))
+#define EVAL2(...)           EVAL1(EVAL1(__VA_ARGS__))
+#define EVAL1(...)           __VA_ARGS__
+
+/*===========================================================================
+  Defer macros: these help โ€œhideโ€ recursive calls for additional expansion passes.
+===========================================================================*/
+#define NULL_FN()
+#define DEFER1(m)            m NULL_FN()
+#define DEFER2(m)            m NULL_FN NULL_FN()()
+#define DEFER3(m)            m NULL_FN NULL_FN NULL_FN()()()
+#define DEFER4(m)            m NULL_FN NULL_FN NULL_FN NULL_FN()()()()
+
+/*===========================================================================
+  Quantifiers
+===========================================================================*/
+
+#define _FIND(predicate ,...) \
+  IF \
+    ( NOT_EXISTS(__VA_ARGS__) ) \
+    () \
+    (IF \
+      ( predicate(FIRST(__VA_ARGS__)) ) \
+      ( FIRST( ,__VA_ARGS__) )                    \
+      ( DEFER3(_FIND_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
+     )
+#define _FIND_CONFEDERATE() _FIND
+
+// number of evals required depends upon length of not found list prefix
+#define FIND(predicate ,...) EVAL( _FIND(predicate ,__VA_ARGS__) )
+
+#define _FIND_ITEM(item ,...) \
+  IF \
+    ( NOT_EXISTS(__VA_ARGS__) ) \
+    () \
+    (IF \
+      ( EQ(item ,FIRST(__VA_ARGS__)) )             \
+      ( FIRST( ,__VA_ARGS__) )                    \
+      ( DEFER3(_FIND_ITEM_CONFEDERATE) ()(predicate ,REST(__VA_ARGS__)) )     \
+     )
+#define _FIND_ITEM_CONFEDERATE() _FIND_ITEM
+
+// number of evals required depends upon length of not found list prefix
+#define FIND_ITEM(predicate ,...) EVAL( _FIND_ITEM(predicate ,__VA_ARGS__) )
+
+
+
+#endif  
diff --git a/developer/example_cpp/example_A.c b/developer/example_cpp/example_A.c
new file mode 100644 (file)
index 0000000..edc81c6
--- /dev/null
@@ -0,0 +1,34 @@
+// from http://jhnet.co.uk/articles/cpp_magic
+
+#include <stdio.h>
+#define STR(x) #x
+#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
+
+#define NULL_FN()
+#define EVAL1(...) __VA_ARGS__
+
+#define A(n) I like the number n
+
+
+int main(){
+
+  printf(
+    "    I like the number 123\n"
+    "    A (123)\n"
+  );
+  SHOW(A (123));
+  SHOW(A NULL_FN() (123));
+  printf("\n");
+
+  printf(
+    "    I like the number 123\n"
+  );
+  SHOW(EVAL1(A NULL_FN() (123)));
+  printf("\n");
+
+
+   /*
+     ... The reason this works is that when CPP encounters a function-style macro, it recursively expands the macro's arguments before substituting the macro's body and expanding that. ...
+   */
+         
+};
diff --git a/developer/example_cpp/example_eval.c b/developer/example_cpp/example_eval.c
new file mode 100644 (file)
index 0000000..e60af83
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#define STR(x) #x
+#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
+
+int main(void){
+  printf("example_eval.c\n");
+
+  #define NULL_FN()
+  #define NEGATE(x) -x
+  #define NOT_SO_FAST(x)  NEGATE NULL_FN() (x)
+  SHOW(NOT_SO_FAST(5));
+
+  #define BE(x) x
+  SHOW(BE(NOT_SO_FAST(5)))
+}
+
+/*
+  2025-03-27T04:47:02Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > gcc example_eval.c
+
+  2025-03-27T04:47:32Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > ./a.out
+  example_eval.c
+  NOT_SO_FAST(5) โ†’ NEGATE (5)
+  BE(NOT_SO_FAST(5)) โ†’ -5
+
+*/  
diff --git a/developer/example_cpp/example_grow.c b/developer/example_cpp/example_grow.c
new file mode 100644 (file)
index 0000000..74f3cca
--- /dev/null
@@ -0,0 +1,121 @@
+#include <stdio.h>
+#define STR(x) #x
+// no evaluation, and one pass of evaluation
+#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
+
+#define BE(...) __VA_ARGS__
+#define NULL_FN()
+
+#include <stdio.h>
+int main(void){
+  printf("example_grow.c\n");
+  printf("\n");
+
+  // case 1
+  /* 
+    GROW(7) โ†’ 17 * GROW(7)
+    GROW(GROW(5)) โ†’ 17 * GROW(17 * GROW(5))
+  */
+  #define GROW(x) 17 * GROW(x)  
+  SHOW(GROW(7));
+  SHOW(GROW(GROW(5)));
+  printf("\n");
+
+  // case 2
+  // GROW2(11) --> 19 * GROW2 (11)
+  #define GROW2(x) 19 * GROW2 NULL_FN() (x)  
+  SHOW(GROW2(11)) ;
+  printf("\n");
+
+  // case 3
+  // GROW3(13) --> 119 * 19 * GROW2 (13)
+  #define GROW3(x) BE(119 * GROW2 NULL_FN() (x))
+  SHOW(GROW3(13));
+  printf("\n");
+    
+  // case 4
+  /* 
+    `BE` placed on the outside. The idea is that evaluation will return `123 * GROW (15)` and then this will be evaluated resulting in `123 * 123 * GROW(15)`.
+
+    However, any time GROW4 literally spells out GROW4(...) inside its own expansion
+    it will leave it literally and not expand it. 
+
+    Though it is interesting that here that occurs at a higher level in the evaluation tree than the first ocurrance of the recursive call, but still it is in the tree.
+
+    GROW4(15) --> 123 * GROW4 (15)
+  */
+  #define GROW4(x) BE(123 * GROW4 NULL_FN() (x))
+  SHOW(GROW4(15));
+  printf("\n");
+
+  // case 5
+  /*
+    Substitution of the function named followed by a trampoline works.
+
+    The original expression is written in terms of a deferred CONDFEDERATE function
+    instead of in terms of a recursive call to GROW5. cpp can suspect nothing.
+
+    The result is an expression in terms of the unevaluated CONDFEDERATE function.
+
+    The CONFEDERATE function is defined to return the token GROW5. Hence in a subsequent evaluation, and there must be a subsequent evaluation for this to work,  The CONFEDERATE function will run, return GROW5 which is next to its call parenthesis, so then the
+    recursive call will run.
+
+    BE(GROW5(21)) --> 541 * 541 * CONFEDERATE () (21)
+    BE(BE(GROW5(57))) --> 541 * 541 * 541 * CONFEDERATE () (57)
+  */
+  #define GROW5(x) 541 * CONFEDERATE NULL_FN() () (x)
+  #define CONFEDERATE() GROW5
+  SHOW(BE(GROW5(21)));
+  SHOW(BE(BE(GROW5(57))));
+  printf("\n");
+
+  // case 6
+  /*
+    Once a recursively called function is marked, or 'colored' it can never be expanded, even when passed through to another variable and separately evaluation.
+   */
+  #define GROW6(x) 1029 * GROW6 NULL_FN() (x)
+  #define RESULT1 GROW6(51)
+  SHOW(RESULT1);
+  SHOW(BE(RESULT1));
+  printf("\n");
+  // RESULT1 --> 1029 * GROW6 (51)
+  // BE(RESULT1) --> 1029 * GROW6 (51)
+
+  // case 7
+  #define RESULT2 GROW6(151)
+  SHOW(RESULT2);
+  SHOW(BE(RESULT2));
+  printf("\n");
+  // RESULT2 --> 1029 * GROW6 (151)
+  // BE(RESULT2) --> 1029 * GROW6 (151)
+
+}
+/*
+  2025-03-27T10:45:39Z[developer]
+Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+> gcc example_grow.c
+
+2025-03-27T11:43:19Z[developer]
+Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+> ./a.out 
+example_grow.c
+
+GROW(7) --> 17 * GROW(7)
+GROW(GROW(5)) --> 17 * GROW(17 * GROW(5))
+
+GROW2(11) --> 19 * GROW2 (11)
+
+GROW3(13) --> 119 * 19 * GROW2 (13)
+
+GROW4(15) --> 123 * GROW4 (15)
+
+BE(GROW5(21)) --> 541 * 541 * CONFEDERATE () (21)
+BE(BE(GROW5(57))) --> 541 * 541 * 541 * CONFEDERATE () (57)
+
+RESULT1 --> 1029 * GROW6 (51)
+BE(RESULT1) --> 1029 * GROW6 (51)
+
+RESULT2 --> 1029 * GROW6 (151)
+BE(RESULT2) --> 1029 * GROW6 (151)
+
+*/
diff --git a/developer/example_cpp/example_grow2.c b/developer/example_cpp/example_grow2.c
new file mode 100644 (file)
index 0000000..a421469
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+#define STR(...) #__VA_ARGS__
+// no evaluation, and one pass of evaluation
+#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
+
+#define BE(...) __VA_ARGS__
+
+#define NULL_FN() 
+#define GROW(x)     19 * _GROW NULL_FN() ()(x)
+#define _GROW() GROW
+
+
+int main(void)
+{
+    printf("One-trampoline minimal example:\n\n");
+
+    //19 * _GROW ()(7)
+    SHOW(GROW(7));
+
+    // 19 * 19 * _GROW ()(7)
+    SHOW(BE(GROW(7)));
+
+    // 19 * 19 * 19 * _GROW ()(7)
+    SHOW(BE(BE(GROW(7))));
+
+
+    return 0;
+}
diff --git a/developer/example_cpp/example_recurse.c b/developer/example_cpp/example_recurse.c
new file mode 100644 (file)
index 0000000..5a4b4e0
--- /dev/null
@@ -0,0 +1,54 @@
+// from http://jhnet.co.uk/articles/cpp_magic
+
+#include <stdio.h>
+
+#define STR(...) #__VA_ARGS__
+// no evaluation, and one pass of evalutation
+#define SHOW(expr) printf("%s --> %s\n", #expr, STR(expr))
+
+#define NULL_FN()
+
+#define EVAL32(...) EVAL16(EVAL16(__VA_ARGS__))
+#define EVAL16(...) EVAL8(EVAL8(__VA_ARGS__))
+#define EVAL8(...) EVAL4(EVAL4(__VA_ARGS__))
+#define EVAL4(...) EVAL2(EVAL2(__VA_ARGS__))
+#define EVAL2(...) EVAL1(EVAL1(__VA_ARGS__))
+#define EVAL1(...) __VA_ARGS__
+
+#define DEFER1(m) m NULL_FN()
+
+#define RECURSE() I am recursive, look: DEFER1(_RECURSE)()()
+#define _RECURSE() RECURSE
+
+
+int main(){
+
+  printf(
+    "No EVAL:\n"
+    "    RECURSE()\n"
+  );
+  SHOW(RECURSE());
+  printf("\n");
+
+  printf(
+    "With EVAL1:\n"
+    "    EVAL1(RECURSE())\n"
+  );
+  SHOW(EVAL1(RECURSE()));
+  printf("\n"); 
+
+  printf(
+    "With EVAL2:\n"
+    "    EVAL2(RECURSE())\n"
+  );
+  SHOW(EVAL2(RECURSE()));
+  printf("\n"); 
+
+  printf(
+    "With EVAL32:\n"
+    "    EVAL32(RECURSE())\n"
+  );
+  SHOW(EVAL32(RECURSE()));
+  printf("\n");
+         
+};
diff --git a/developer/example_cpp/try_1_exists.c b/developer/example_cpp/try_1_exists.c
new file mode 100644 (file)
index 0000000..c2ca07d
--- /dev/null
@@ -0,0 +1,110 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+
+#define F 1
+#define O1 2
+#define O2 3
+#define B 4
+#define A 5
+#define R 6
+#define D 7
+
+
+// Patch for _EXISTS to succeed on 0
+#define _REWRITE_TWION_0 _REWRITE_TWION
+
+int main(void){
+  printf("try_1_exists\n\n");
+
+  // Constant macros
+  int x COMMA y = 1;  // Tests that COMMA = ,
+  printf("y? %d\n", y);
+  printf("\n");
+
+  // Token paste test
+  int _cat_result = CAT2(CAT3(F ,O1 ,O2) ,CAT4(B ,A ,R ,D));
+  printf("FOOBARD %d\n" ,_cat_result);
+  printf("\n");
+
+  // Selector macros
+  int first = _FIRST(11 ,22 ,33);    // โ†’ 11
+  int second = _SECOND(11 ,22 ,33);  // โ†’ 22
+  printf("_FIRST(11 ,22 ,33) = %d\n", first);
+  printf("_SECOND(11 ,22 ,33) = %d\n", second);
+  printf("\n");
+
+  // Existence detection
+  int empty = EXISTS_ITEM();         // โ†’ 1 (rewrite hits)
+  int empty_0 = EXISTS_ITEM(0);      // โ†’ 1 (rewrite hits)
+  int empty_1 = EXISTS_ITEM(1);      // โ†’ 0 (no rewrite)
+  int empty_f = EXISTS_ITEM(hello);  // โ†’ 0
+
+  printf("EXISTS_ITEM() = %d\n", empty);
+  printf("EXISTS_ITEM(0) = %d\n", empty_0);
+  printf("EXISTS_ITEM(1) = %d\n", empty_1);
+  printf("EXISTS_ITEM(hello) = %d\n", empty_f);
+  printf("\n");
+
+  // Not Existence detection
+  empty = NOT_EXISTS_ITEM();         // โ†’ 1 (rewrite hits)
+  empty_0 = NOT_EXISTS_ITEM(0);      // โ†’ 1 (rewrite hits)
+  empty_1 = NOT_EXISTS_ITEM(1);      // โ†’ 0 (no rewrite)
+  empty_f = NOT_EXISTS_ITEM(hello);  // โ†’ 0
+
+  printf("NOT_EXISTS_ITEM() = %d\n", empty);
+  printf("NOT_EXISTS_ITEM(0) = %d\n", empty_0);
+  printf("NOT_EXISTS_ITEM(1) = %d\n", empty_1);
+  printf("NOT_EXISTS_ITEM(hello) = %d\n", empty_f);
+  printf("\n");
+
+
+  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
+  int empty_11 = EXISTS(10,11,12); // this is a legal call
+  int empty_12 = EXISTS(); 
+
+  // printf("EXISTS_ITEM(10,11,12) = %d\n", empty_10);
+  printf("EXISTS(10,11,12) = %d\n", empty_11);
+  printf("EXISTS() = %d\n", empty_12);
+  printf("\n");
+
+  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
+  empty_11 = NOT_EXISTS(10,11,12); // this is a legal call
+  empty_12 = NOT_EXISTS(); 
+
+  // printf("NOT_EXISTS_ITEM(10,11,12) = %d\n", empty_10);
+  printf("NOT_EXISTS(10,11,12) = %d\n", empty_11);
+  printf("NOT_EXISTS() = %d\n", empty_12);
+  printf("\n");
+
+
+  return 0;
+}
+
+/*
+  2025-03-27T12:38:04Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > gcc try_1_exists.c 
+
+  2025-03-27T12:40:32Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > ./a.out
+  _CAT(FOO ,BAR) โ†’ 12345
+
+  _FIRST(11 ,22 ,33) = 11
+  _SECOND(11 ,22 ,33) = 22
+
+  EXISTS_ITEM() = 0
+  EXISTS_ITEM(0) = 1
+  EXISTS_ITEM(1) = 1
+  EXISTS_ITEM(hello) = 1
+
+  NOT_EXISTS_ITEM() = 1
+  NOT_EXISTS_ITEM(0) = 0
+  NOT_EXISTS_ITEM(1) = 0
+  NOT_EXISTS_ITEM(hello) = 0
+
+  EXISTS(10,11,12) = 1
+  EXISTS() = 0
+
+  NOT_EXISTS(10,11,12) = 0
+  NOT_EXISTS() = 1
+*/
diff --git a/developer/example_cpp/try_2_connectors.c b/developer/example_cpp/try_2_connectors.c
new file mode 100644 (file)
index 0000000..98078f1
--- /dev/null
@@ -0,0 +1,200 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+
+int main(void){
+
+  //--------------------------------------------------------------------------
+  // Existence Checks (sanity anchor)
+  //--------------------------------------------------------------------------
+
+  #define x0 
+  SHOW(  EXISTS_ITEM(x0) );       // โ†’ 0 (assumed undefined)
+  SHOW(  NOT_EXISTS_ITEM(x0) );   // โ†’ 1
+  printf("\n");
+
+  SHOW(  MATCH(x0) );
+  SHOW(  NOT_MATCH(x0) );
+  printf("\n");
+
+  //--------------------------------------------------------------------------
+  // Primitive Connectors
+  //--------------------------------------------------------------------------
+
+  SHOW( _NOT(0) );  // _RWR_NOT_0 is defined โ†’ MATCH โ†’ 1
+  SHOW( _NOT(1) );  // no rule โ†’ MATCH fails โ†’ 0
+  printf("\n");
+
+  SHOW( _AND(0 ,0) );  // rule defined โ†’ MATCH โ†’ 1
+  SHOW( _AND(1 ,0) );  // rule defined โ†’ MATCH โ†’ 1
+  SHOW( _AND(0 ,1) );  // rule defined โ†’ MATCH โ†’ 1
+  SHOW( _AND(1 ,1) );  // rule defined โ†’ MATCH โ†’ 1
+  SHOW( _AND(1 ,x) );  // not legal args, but worked, rule missing โ†’ MATCH fails โ†’ 0
+  printf("\n");
+
+  SHOW( _OR(0 ,0) );   // rule defined โ†’ NOT_MATCH โ†’ 0
+  SHOW( _OR(0 ,1) );   // rule missing โ†’ NOT_MATCH โ†’ 1
+  SHOW( _OR(1 ,0) );   // rule missing โ†’ NOT_MATCH โ†’ 1
+  SHOW( _OR(1 ,1) );   // rule missing โ†’ NOT_MATCH โ†’ 1
+  printf("\n");
+
+  //--------------------------------------------------------------------------
+  // Logical Connectors (BOOL + AND/OR/NOT)
+  //--------------------------------------------------------------------------
+
+  printf("x0 is a macro with an empty definition");
+
+  SHOW( _BOOL(0) );       // 0
+  SHOW( _BOOL(1) );       // 1
+  SHOW( _BOOL(2) );       //  1 because it exists
+  SHOW( _BOOL(x0) );       // 0 because it does not exit (see the #define at the top)
+  printf("\n");
+
+  SHOW( BOOL(0) );       // _FIRST = 0, EXISTS_ITEM(_FIRST) = 0 โ†’ _AND(0 ,1) โ†’ 0
+  SHOW( BOOL(1) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
+  SHOW( BOOL(10) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
+  SHOW( BOOL() );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
+  SHOW( BOOL(x0) );       // EXISTS_ITEM(1) = 0 โ†’ BOOL = 0
+  printf("\n");
+
+  SHOW( NOT(0) );        // BOOL = 0 โ†’ NOT(0) = _NOT(0) = 1
+  SHOW( NOT(1) );        // BOOL = 0 โ†’ NOT(0) = 1
+  SHOW( NOT() );        // BOOL = 0 โ†’ NOT(0) = 1
+  SHOW( NOT(10) );        // BOOL = 0 โ†’ NOT(0) = 1
+  printf("\n");
+
+  SHOW( AND(1 ,0) );     // 0
+  SHOW( AND(1 ,1) );     // BOOL(1), BOOL(1) = 0,0 โ†’ AND(0 ,0) = _AND(0 ,0) = 1
+  printf("\n");
+
+  SHOW( OR(0 ,0) );      // BOOL(1), BOOL(0) = 0,0 โ†’ OR(0 ,0) = _OR(0 ,0) = 0
+  SHOW( OR(1 ,0) );      // BOOL(1), BOOL(0) = 0,0 โ†’ OR(0 ,0) = _OR(0 ,0) = 0
+  printf("\n");
+
+  //--------------------------------------------------------------------------
+  // Compound Connectors
+  //--------------------------------------------------------------------------
+
+  // Double NOT
+  SHOW( NOT(NOT(0)) );     // โ†’ NOT(1) โ†’ _NOT(1) โ†’ 0
+  SHOW( NOT(NOT(1)) );     // โ†’ NOT(0) โ†’ _NOT(0) โ†’ 1
+
+  // Triple NOT
+  SHOW( NOT(NOT(NOT(0))) );  // โ†’ NOT(0) โ†’ _NOT(0) โ†’ 1
+  SHOW( NOT(NOT(NOT(1))) );  // โ†’ NOT(1) โ†’ _NOT(1) โ†’ 0
+  printf("\n");
+
+  // Nested AND
+  SHOW( AND(1 ,AND(1 ,0)) );  // AND(1 ,AND(1 ,0)) โ†’ AND(1 ,0) โ†’ _AND(1 ,0) = 0
+  SHOW( AND(1 ,AND(1 ,1)) );  // โ†’ AND(1 ,1) โ†’ _AND(1 ,1) = 1
+  printf("\n");
+
+  // Nested OR
+  SHOW( OR(0 ,OR(0 ,1)) );    // โ†’ OR(0 ,1) โ†’ _OR(0 ,1) = 1
+  SHOW( OR(0 ,OR(0 ,0)) );    // โ†’ OR(0 ,0) โ†’ _OR(0 ,0) = 0
+  printf("\n");
+
+  // Mixed nesting
+  SHOW( AND(NOT(0) ,1) );     // โ†’ AND(1 ,1) โ†’ _AND(1 ,1) = 1
+  SHOW( AND(NOT(1) ,1) );     // โ†’ AND(0 ,1) โ†’ _AND(0 ,1) = 0
+  SHOW( OR(NOT(1) ,1) );      // โ†’ OR(0 ,1) โ†’ _OR(0 ,1) = 1
+  SHOW( OR(NOT(0) ,0) );      // โ†’ OR(1 ,0) โ†’ _OR(1 ,0) = 1
+  printf("\n");
+
+  // Deep mix
+  SHOW( NOT(AND(1 ,NOT(1))) );  // AND(1 ,0) = _AND(1 ,0) = 0 โ†’ NOT(0) = _NOT(0) = 1
+  SHOW( NOT(OR(0 ,NOT(0))) );   // OR(0 ,1) = _OR(0 ,1) = 1 โ†’ NOT(1) = _NOT(1) = 0
+  printf("\n");
+
+  // Asymmetric nesting
+  SHOW( AND(OR(0 ,1) ,AND(1 ,1)) ); // OR(0 ,1) = 1, AND(1 ,1) = 1 โ†’ AND(1 ,1) = 1
+  SHOW( OR(AND(1 ,0) ,AND(1 ,1)) ); // AND(1 ,0) = 0, AND(1 ,1) = 1 โ†’ OR(0 ,1) = 1
+  printf("\n");
+
+  return 0;
+}
+/*
+  2025-03-27T12:59:39Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > gcc try_2_connectors.c 
+
+  2025-03-27T13:00:11Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  > ./a.out
+  EXISTS_ITEM(x0) --> 0
+  NOT_EXISTS_ITEM(x0) --> 1
+
+  MATCH(x0) --> MATCH()
+  NOT_MATCH(x0) --> NOT_MATCH()
+
+  _NOT(0) --> 1
+  _NOT(1) --> 0
+
+  _AND(0 ,0) --> 0
+  _AND(1 ,0) --> 0
+  _AND(0 ,1) --> 0
+  _AND(1 ,1) --> 1
+  _AND(1 ,x) --> 0
+
+  _OR(0 ,0) --> 0
+  _OR(0 ,1) --> 1
+  _OR(1 ,0) --> 1
+  _OR(1 ,1) --> 1
+
+  _EQ(0 ,0) --> 1
+  _EQ(1 ,1) --> 1
+  _EQ(0 ,1) --> 0
+  _EQ(x ,x) --> 0
+
+  _NOT_EQ(0 ,1) --> 1
+  _NOT_EQ(0 ,0) --> 0
+
+  _BOOL_2(0) --> 0
+  _BOOL_2(1) --> 1
+  _BOOL_2(2) --> 1
+  _BOOL_2(x0) --> 0
+
+  BOOL(0) --> 0
+  BOOL(1) --> 1
+  BOOL(10) --> 1
+  BOOL() --> 0
+  BOOL(x0) --> 0
+
+  NOT(0) --> 1
+  NOT(1) --> 0
+  NOT() --> 1
+  NOT(10) --> 0
+
+  AND(1 ,0) --> 0
+  AND(1 ,1) --> 1
+
+  OR(0 ,0) --> 0
+  OR(1 ,0) --> 1
+
+  NOT(NOT(0)) --> 0
+  NOT(NOT(1)) --> 1
+  NOT(NOT(NOT(0))) --> 1
+  NOT(NOT(NOT(1))) --> 0
+
+  AND(1 ,AND(1 ,0)) --> 0
+  AND(1 ,AND(1 ,1)) --> 1
+
+  OR(0 ,OR(0 ,1)) --> 1
+  OR(0 ,OR(0 ,0)) --> 0
+
+  AND(NOT(0) ,1) --> 1
+  AND(NOT(1) ,1) --> 0
+  OR(NOT(1) ,1) --> 1
+  OR(NOT(0) ,0) --> 1
+
+  NOT(AND(1 ,NOT(1))) --> 1
+  NOT(OR(0 ,NOT(0))) --> 0
+
+  AND(OR(0 ,1) ,AND(1 ,1)) --> 1
+  OR(AND(1 ,0) ,AND(1 ,1)) --> 1
+
+
+  2025-03-27T13:00:12Z[developer]
+  Thomas-developer@Stanleyยง/home/Thomas-masu/developer/N/developer/exampleยง
+  >
+*/
+
+  
diff --git a/developer/example_cpp/try_3_eq.c b/developer/example_cpp/try_3_eq.c
new file mode 100644 (file)
index 0000000..c388f03
--- /dev/null
@@ -0,0 +1,55 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+
+int main(void){
+
+  //---------------------------------------------------------------------------
+  // EQ Tests โ€” identity and mismatch
+  //---------------------------------------------------------------------------
+
+  SHOW(EQ(0 ,0));      // Expected โ†’ 1
+  SHOW(EQ(1 ,1));      // Expected โ†’ 1
+  SHOW(EQ(0 ,1));      // Expected โ†’ 0
+  SHOW(EQ(1 ,0));      // Expected โ†’ 0
+
+  SHOW(EQ(x ,x));      // Expected โ†’ 0 (no _RWREQ__x__oo__x defined)
+  SHOW(EQ(x ,y));      // Expected โ†’ 0
+
+  //---------------------------------------------------------------------------
+  // NOTEQ Tests โ€” inverse behavior
+  //---------------------------------------------------------------------------
+
+  SHOW(NOT_EQ(0 ,0));  // Expected โ†’ 0 (because EQ โ†’ 1, so EXISTS โ†’ 0)
+  SHOW(NOT_EQ(1 ,1));  // Expected โ†’ 0
+  SHOW(NOT_EQ(0 ,1));  // Expected โ†’ 1
+  SHOW(NOT_EQ(1 ,0));  // Expected โ†’ 1
+
+  SHOW(NOT_EQ(x ,x));  // Expected โ†’ 1 (EQ not defined โ†’ NOTEQ = 1)
+  SHOW(NOT_EQ(x ,y));  // Expected โ†’ 1
+
+  //---------------------------------------------------------------------------
+  // Mixed cases with macros
+  //---------------------------------------------------------------------------
+
+  #define XSYM 0
+  #define YSYM 1
+
+  SHOW(EQ(XSYM ,XSYM));      // Expected โ†’ 1 (0,0)
+  SHOW(EQ(XSYM ,YSYM));      // Expected โ†’ 0 (0,1)
+  SHOW(NOT_EQ(XSYM ,YSYM));  // Expected โ†’ 1
+
+  SHOW(EQ(XSYM ,0));         // Expected โ†’ 1
+  SHOW(EQ(XSYM ,1));         // Expected โ†’ 0
+
+  SHOW(NOT_EQ(YSYM ,0));     // Expected โ†’ 1
+  SHOW(NOT_EQ(YSYM ,1));     // Expected โ†’ 0
+
+  //---------------------------------------------------------------------------
+  // Edge case: undefined symbol
+  //---------------------------------------------------------------------------
+
+  SHOW(EQ(z ,z));        // Expected โ†’ 0
+  SHOW(NOT_EQ(z ,z));    // Expected โ†’ 1
+
+  printf("\n");
+  return 0;
+}
diff --git a/developer/example_cpp/try_4_if.c b/developer/example_cpp/try_4_if.c
new file mode 100644 (file)
index 0000000..4d9d3ae
--- /dev/null
@@ -0,0 +1,62 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+
+int main(void){
+
+  //---------------------------------------------------------------------------
+  // Basic boolean cases
+  //---------------------------------------------------------------------------
+
+  SHOW(IF_ELSE(1)(yes)(no)); 
+  SHOW(IF_ELSE(0)(yes)(no));        // โ†’ no
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Symbolic identifiers
+  //---------------------------------------------------------------------------
+  SHOW(IF_ELSE(TRUE)(ok)(fail));    // โ†’ ok
+  SHOW(IF_ELSE(FALSE)(ok)(fail));   // โ†’ fail
+  SHOW(IF_ELSE(foo)(alpha)(omega)); // โ†’ omega (foo is undefined)
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Logic expressions
+  //---------------------------------------------------------------------------
+  SHOW(IF_ELSE(AND(1 ,1))(pass)(fail));  // โ†’ pass
+  SHOW(IF_ELSE(OR(0 ,0))(yes)(no));      // โ†’ no
+  SHOW(IF_ELSE(NOT(0))(on)(off));        // โ†’ on
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Code-like output
+  //---------------------------------------------------------------------------
+  SHOW(IF_ELSE(1)(int x = 1;)(int x = 2;));  // โ†’ int x = 1;
+  SHOW(IF_ELSE(0)(int x = 1;)(int x = 2;));  // โ†’ int x = 2;
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Comma usage in true/false branches
+  //---------------------------------------------------------------------------
+  SHOW(IF_ELSE(1)(a ,b ,c)(x ,y ,z));  // โ†’ a ,b ,c
+  SHOW(IF_ELSE(0)(a ,b ,c)(x ,y ,z));  // โ†’ x ,y ,z
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Empty condition
+  //---------------------------------------------------------------------------
+  SHOW(IF_ELSE()(true)(false));       // โ†’ false (BOOL() = 0)
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // Nested IF_ELSE
+  //---------------------------------------------------------------------------
+  SHOW(
+    IF_ELSE(AND(1 ,1))(
+      IF_ELSE(0)(inner_true)(inner_false)
+    )(
+      outer_false
+    )
+  ); // โ†’ inner_false
+  printf("\n");
+
+  return 0;
+}
diff --git a/developer/example_cpp/try_5_access.c b/developer/example_cpp/try_5_access.c
new file mode 100644 (file)
index 0000000..aee6c94
--- /dev/null
@@ -0,0 +1,46 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+
+int main(void){
+
+  //---------------------------------------------------------------------------
+  // FIRST
+  //---------------------------------------------------------------------------
+
+  SHOW(FIRST(foo));                 // โ†’ foo         (only pad, no args)
+  SHOW(FIRST(foo ,a));             // โ†’ a
+  SHOW(FIRST(foo ,a ,b ,c));       // โ†’ a
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // REST
+  //---------------------------------------------------------------------------
+
+  SHOW(REST());                    // โ†’ (empty)
+  SHOW(REST(a));                  // โ†’ (empty)
+  SHOW(REST(a ,b));               // โ†’ b
+  SHOW(REST(a ,b ,c ,d));         // โ†’ b ,c ,d
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // SECOND
+  //---------------------------------------------------------------------------
+
+  SHOW(SECOND(X));                // โ†’ X         (only pad)
+  SHOW(SECOND(X ,a));             // โ†’ X         (only one arg, fallback to pad)
+  SHOW(SECOND(X ,a ,b));          // โ†’ b
+  SHOW(SECOND(X ,a ,b ,c));       // โ†’ b
+  printf("\n");
+
+  //---------------------------------------------------------------------------
+  // THIRD
+  //---------------------------------------------------------------------------
+
+  SHOW(THIRD(X));                 // โ†’ X         (pad returned)
+  SHOW(THIRD(X ,a));              // โ†’ X
+  SHOW(THIRD(X ,a ,b));           // โ†’ X
+  SHOW(THIRD(X ,a ,b ,c));        // โ†’ c
+  SHOW(THIRD(X ,a ,b ,c ,d));     // โ†’ c
+  printf("\n");
+
+  return 0;
+}
diff --git a/developer/example_cpp/try_6_list.c b/developer/example_cpp/try_6_list.c
new file mode 100644 (file)
index 0000000..a9ba619
--- /dev/null
@@ -0,0 +1,60 @@
+#include "../cc๐Ÿ–‰/cpp_ext_0.c"
+#include "../cc๐Ÿ–‰/cpp_ext_1.c"
+
+#define LIST Integer ,Float ,Char ,Void 
+
+// register equality
+#define EQ__Integer__oo__Integer
+#define EQ__Float__oo__Float
+#define EQ__Char__oo__Char
+#define EQ__Void__oo__Void
+
+// make predicates
+#define IS_Integer(x) EQ(x ,Integer)
+#define IS_Float(x)   EQ(x ,Float)
+#define IS_Missing(x) EQ(x ,Missing)
+#define IS_Char(x)    EQ(x ,Char)
+#define IS_Void(x)    EQ(x ,Void)
+
+int main(void){
+
+  SHOW(IS_Char(Integer));
+  SHOW(IS_Char(Char));
+  printf("\n");
+
+  SHOW( FIND(IS_Char ,) );
+  SHOW( FIND(IS_Char ,Char) );  // โ†’ Char
+  SHOW( FIND(IS_Char ,Integer) );  // โ†’ 
+  printf("\n");
+
+  SHOW( FIND(IS_Char ,Integer ,Void) );  // โ†’ 
+  SHOW( FIND(IS_Void ,Integer ,Void) );  // โ†’ 
+  printf("\n");
+
+  SHOW( FIND(IS_Integer ,LIST) ); 
+  SHOW( FIND(IS_Float ,LIST) ); 
+  SHOW( FIND(IS_Missing ,LIST) ); 
+  SHOW( FIND(IS_Char ,LIST) ); 
+  SHOW( FIND(IS_Void ,LIST) ); 
+  SHOW( FIND(IS_big ,LIST) ); // literal 'IS_big' will be seen as true
+  printf("\n");
+
+  SHOW( FIND_ITEM(Char ,) );
+  SHOW( FIND_ITEM(Char ,Char) );  // โ†’ Char
+  SHOW( FIND_ITEM(Char ,Integer) );  // โ†’ 
+  printf("\n");
+
+  SHOW( FIND_ITEM(Char ,Integer ,Void) );  // โ†’ 
+  SHOW( FIND_ITEM(Void ,Integer ,Void) );  // โ†’ 
+  printf("\n");
+
+  SHOW( FIND_ITEM(Integer ,LIST) ); 
+  SHOW( FIND_ITEM(Float ,LIST) ); 
+  SHOW( FIND_ITEM(Missing ,LIST) ); 
+  SHOW( FIND_ITEM(Char ,LIST) ); 
+  SHOW( FIND_ITEM(Void ,LIST) ); 
+  SHOW( FIND_ITEM(big ,LIST) ); 
+  printf("\n");
+
+  return 0;
+}
index cfc2138..246d8df 100755 (executable)
@@ -13,10 +13,6 @@ set -e
 set -x
 
   cd "$REPO_HOME"/developer || exit 1
-
-  pushd python
-    ./fill_template
-  popd
   /bin/make -f tool๐Ÿ–‰/makefile $@
 
 set +x
index 7b3660f..8dfa07c 100644 (file)
@@ -3,7 +3,13 @@ RT-INCOMMON:=$(REPO_HOME)/tool_shared/third_party/RT-project-share/release
 
 include $(RT-INCOMMON)/make/environment_RT_0
 
-CFLAGS+=-Werror -Wno-macro-redefined -include "$(RT-INCOMMON)/make/RT_0.h"
+# to compile only the example directory
+# comment these out for a normal compile
+SRCDIR_List=example
+# if the .lib.c interfaces are needed:
+CFLAGS+=-Icc๐Ÿ–‰
+
+CFLAGS+= -include "$(RT-INCOMMON)/make/RT_0.h"
 LINKFLAGS+= -l$(PROJECT)
 LIBFILE=$(LIBDIR)/lib$(PROJECT).a