~ chicken-core (master) 75e6b568258e0f10adbd5da99d641d8472953b21


commit 75e6b568258e0f10adbd5da99d641d8472953b21
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Thu Aug 6 14:44:43 2026 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Thu Aug 6 14:44:43 2026 +0200

    Document reusable and shareable closure merging

diff --git a/csc.scm b/csc.scm
index e7882d63..e993b635 100644
--- a/csc.scm
+++ b/csc.scm
@@ -429,7 +429,7 @@ Usage: #{csc} [OPTION ...] [FILENAME ...]
     -strict-types                  assume variable do not change their type
     -lfa2                          perform additional lightweight flow-analysis pass
     -unroll-limit LIMIT            specifies inlining limit for self-recursive calls
-    -merge-resuable-closures       enables closure resue
+    -merge-resuable-closures       enables closure reuse
     -merge-shareable-closures      enables closure sharing
 
   Configuration options:
diff --git a/manual/Using the compiler b/manual/Using the compiler
index 7dd935f0..165ee39d 100644
--- a/manual/Using the compiler	
+++ b/manual/Using the compiler	
@@ -117,9 +117,9 @@ the source text should be read from standard input.
 ; -nursery NUMBER :
 ; -stack-size NUMBER : Sets the size of the first heap-generation of the generated executable to {{NUMBER}} bytes. The parameter may be followed by a {{M}} ({{m}}) or {{K}} ({{k}}) suffix.  The default stack-size depends on the target platform.
 
-; -merge-reusable-closures : XXX
+; -merge-reusable-closures : Allows merging of reusable closures.  When multiple procedures close over the exact same set of variables, the outermost procedure's closure gets re-used inside the inner procedures.  This reduces memory usage and saves on copying of variables which should be faster and also less generated code, especially for large closures.
 
-; -merge-shareable-closures : XXX
+; -merge-shareable-closures : Allows merging of shareable closures.  Like the above, except this also allows procedures to share a closure when the set of variables differ.  Currently, this only works for non-escaping closures which strictly grow their containing procedure's set of closed-over variables, and only if there is exactly one sub-closure.  This turns out to be more than you would expect due to many internal procedures introduced during CPS transformation.
 
 ; -optimize-leaf-routines : Enable leaf routine optimization.
 
diff --git a/support.scm b/support.scm
index 41d87e22..f5346f33 100644
--- a/support.scm
+++ b/support.scm
@@ -1855,7 +1855,7 @@ Usage: chicken FILENAME [OPTION ...]
     -strict-types                assume variable do not change their type
     -lfa2                        perform additional lightweight flow-analysis pass
     -unroll-limit LIMIT          specifies inlining limit for self-recursive calls
-    -merge-resuable-closures     enables closure resue
+    -merge-resuable-closures     enables closure reuse
     -merge-shareable-closures    enables closure sharing
 
   Configuration options:
Trap