~ chicken-core (chicken-5) 6ab0b9f6b99c230f52a040d26a460ab6d99dc4ef


commit 6ab0b9f6b99c230f52a040d26a460ab6d99dc4ef
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Wed Dec 8 05:08:07 2010 -0500
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Wed Dec 8 05:08:07 2010 -0500

    added -M/-module option

diff --git a/batch-driver.scm b/batch-driver.scm
index 9650dfda..0d6372c8 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -92,6 +92,7 @@
 	(dumpnodes #f)
 	(start-time #f)
 	(upap #f)
+	(wrap-module (memq 'module options))
 	(ssize (or (memq 'nursery options) (memq 'stack-size options))) )
 
     (define (cputime) (current-milliseconds))
@@ -423,7 +424,13 @@
 	     (set! ##sys#explicit-library-modules
 	       (append ##sys#explicit-library-modules uses-units))
 	     (set! forms (cons `(declare (uses ,@uses-units)) forms)) )
-	   (let* ([exps0 (map canonicalize-expression (append initforms forms))]
+	   (let* ((exps0 (map canonicalize-expression
+			      (let ((forms (append initforms forms)))
+				(if wrap-module
+				    `((##core#module main () 
+						     (import scheme chicken)
+						     ,@forms))
+				    forms))))
 		  [pvec (gensym)]
 		  [plen (length profile-lambda-list)]
 		  [exps (append
diff --git a/c-platform.scm b/c-platform.scm
index 94ec7d37..ae4a52a4 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -89,7 +89,7 @@
     disable-stack-overflow-checks raw 
     emit-external-prototypes-first release local inline-global
     analyze-only dynamic scrutinize no-argc-checks no-procedure-checks
-    no-procedure-checks-for-toplevel-bindings
+    no-procedure-checks-for-toplevel-bindings module
     no-bound-checks no-procedure-checks-for-usual-bindings no-compiler-syntax
     no-parentheses-synonyms no-symbol-escape r5rs-syntax emit-all-import-libraries
     setup-mode unboxing no-module-registration) )
diff --git a/csc.scm b/csc.scm
index 55407855..4067ea07 100644
--- a/csc.scm
+++ b/csc.scm
@@ -140,7 +140,7 @@
     -no-symbol-escape -no-parentheses-synonyms -r5rs-syntax
     -no-argc-checks -no-bound-checks -no-procedure-checks -no-compiler-syntax
     -emit-all-import-libraries -setup-mode -unboxing -no-elevation -no-module-registration
-    -no-procedure-checks-for-usual-bindings
+    -no-procedure-checks-for-usual-bindings -module
     -no-procedure-checks-for-toplevel-bindings))
 
 (define-constant complex-options
@@ -150,12 +150,15 @@
     -disable-warning			; OBSOLETE
     -emit-inline-file -types
     -feature -debug-level -heap-growth -heap-shrinkage -heap-initial-size -consult-inline-file
-    -emit-import-library -static-extension -no-feature))
+    -emit-import-library
+    -static-extension 			; DEPRECATED
+    -no-feature))
 
 (define-constant shortcuts
   '((-h "-help")
     (-s "-shared")
     (-S "-scrutinize")
+    (-M "-module")
     (|-P| "-check-syntax")
     (|-V| "-version")
     (-f "-fixnum-arithmetic")
@@ -322,11 +325,11 @@ Usage: #{csc} FILENAME | OPTION ...
   Syntax related options:
 
     -i -case-insensitive           don't preserve case of read symbols    
-    -K  -keyword-style STYLE       enable alternative keyword-syntax
+    -K -keyword-style STYLE        enable alternative keyword-syntax
                                     (prefix, suffix or none)
-        -no-parentheses-synonyms   disables list delimiter synonyms
-        -no-symbol-escape          disables support for escaped symbols
-        -r5rs-syntax               disables the Chicken extensions to
+       -no-parentheses-synonyms    disables list delimiter synonyms
+       -no-symbol-escape           disables support for escaped symbols
+       -r5rs-syntax                disables the Chicken extensions to
                                     R5RS syntax
     -compile-syntax                macros are made available at run-time
     -j -emit-import-library MODULE write compile-time module information into
@@ -334,6 +337,7 @@ Usage: #{csc} FILENAME | OPTION ...
     -J -emit-all-import-libraries  emit import-libraries for all defined modules
     -no-module-registration        do not generate module registration code
     -no-compiler-syntax            disable expansion of compiler-macros
+    -M -module                     wrap compiled code into implicit module
 
   Translation options:
 
@@ -432,8 +436,6 @@ Usage: #{csc} FILENAME | OPTION ...
     -static-libs                   link with static CHICKEN libraries
     -static                        generate completely statically linked
                                     executable
-    -static-extension NAME         link extension NAME statically
-                                    (if available)
     -F<DIR>                        pass \"-F<DIR>\" to C compiler
                                     (add framework header path on Mac OS X)
     -framework NAME                passed to linker on Mac OS X
@@ -626,7 +628,7 @@ EOF
 		(set! required-extensions (append required-extensions (list (car rest))))
 		(t-options "-require-extension" (car rest))
 		(set! rest (cdr rest)) ]
-	       [(-static-extension)
+	       [(-static-extension)	;DEPRECATED
 		(check s rest)
 		(set! static-extensions (append static-extensions (list (car rest))))
 		(t-options "-static-extension" (car rest))
diff --git a/manual/Unit library b/manual/Unit library
index e807986d..baf5d34b 100644
--- a/manual/Unit library	
+++ b/manual/Unit library	
@@ -408,11 +408,11 @@ Returns a keyword with the name {{STRING}}.
 
 <procedure>(argv)</procedure>
 
-Return a list of all supplied command-line arguments. The first item in
-the list is a string containing the name of the executing program. The
-other items are the arguments passed to the application. This list is
-freshly created on every invocation of {{(argv)}}. It depends on
-the host-shell whether arguments are expanded ('globbed') or not.
+Return a list of all supplied command-line arguments. The first item
+in the list is a string containing the name of the executing
+program. The other items are the arguments passed to the
+application. It depends on the host-shell whether arguments are
+expanded ('globbed') or not.
 
 
 ==== exit
diff --git a/manual/Using the compiler b/manual/Using the compiler
index 0a515c41..ebbff6f5 100644
--- a/manual/Using the compiler	
+++ b/manual/Using the compiler	
@@ -119,6 +119,8 @@ the source text should be read from standard input.
 
 ; -local : Assume toplevel variables defined in the current compilation unit are not externally modified. This gives the compiler more opportunities for inlining. Note that this may result in counter-intuitive and non-standard behaviour: an asssignment to an exported toplevel variable executed in a different compilation unit or in evaluated code will possibly not be seen by code executing in the current compilation unit.
 
+; -module : wraps the compiled code in an implicit module named {{main}}, importing the {{scheme}} and {{chicken}} modules.
+
 ; -no-argc-checks : disable argument count checks
 
 ; -no-bound-checks : disable bound variable checks
diff --git a/support.scm b/support.scm
index 76c91760..da244319 100644
--- a/support.scm
+++ b/support.scm
@@ -1256,6 +1256,7 @@ Usage: chicken FILENAME OPTION ...
     -emit-all-import-libraries   emit import-libraries for all defined modules
     -no-module-registration      do not generate module registration code
     -no-compiler-syntax          disable expansion of compiler-macros
+    -module                      wrap compiled code into implicit module
 
   Translation options:
 
@@ -1326,8 +1327,6 @@ Usage: chicken FILENAME OPTION ...
     -epilogue FILENAME           include file after main source file
     -dynamic                     compile as dynamically loadable code
     -require-extension NAME      require and import extension NAME
-    -static-extension NAME       import extension NAME but link statically
-                                  (if available)
 
   Obscure options:
 
Trap