On 2015-10-30 8:18, Evan Hanson wrote:
> Yeah, I very nearly omitted the -main-module option, too. It's pretty
> silly and I'd be happy to see it go.
Attached is a patch doing this. I've also pushed these commits to the
"chicken-5-named-module-option" branch.
On 2015-10-30 8:18, Evan Hanson wrote:
> On 2015-10-29 20:06, Peter Bex wrote:
> > This is a bit of a niche option, isn't it? I don't really see the use
> > of it: nothing gets exported anyway, so why should the name of the
> > module matter? Besides, wrapping something in a module isn't really
> > that useful, except maybe to catch errors.
>
> I'd also like to switch the default behaviour to export everything, but
> haven't gotten to testing that out yet. That way it's still useful as a
> "program wrapper" (since you won't be using those exports anyway), but
> also useful when compiling many different files together.
OK, so I think there are two valid options here and I'm not sure which
is better.
1. Make the flag export everything as I suggested before. This works
fine, it's easy to understand, but it's slightly less flexible than
option 2:
2. Keep the flag's behaviour as it is, exporting nothing, and let
users (export ...) any identifiers they want to be exported when
the file is compiled as a module. (This works well since export
forms occurring outside of a module are simply ignored.)
I think I'm partial to #2. That way, the flag still works as a program
linter of sorts, but it's also generally useful as a way to control
compilation in multi-file projects.
Thoughts?
Evan
>From 6c93e9c95648d6585e3c823df82823fa56608735 Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Sat, 31 Oct 2015 14:35:10 +1300
Subject: [PATCH] Remove the somewhat silly "-main-module" option
Users can just type "-module main" instead.
---
NEWS | 3 +--
batch-driver.scm | 5 ++---
c-platform.scm | 2 +-
csc.scm | 3 ---
manual/Using the compiler | 2 --
support.scm | 1 -
tests/runtests.bat | 6 +-----
tests/runtests.sh | 4 +---
8 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/NEWS b/NEWS
index 2bb0a0c..5136e67 100644
--- a/NEWS
+++ b/NEWS
@@ -10,8 +10,7 @@
- Compiler
- Fixed an off by one allocation problem in generated C code for (list ...).
- The "-scrutinize" compiler option has been removed.
- - The "-module" compiler option (aliased as "-m") now expects a module
- name, with the new "-main-module" (or "-M") option defaulting to "main".
+ - The "-module" compiler option (aliased as "-m") now expects a module name.
- Core libraries
- Removed support for memory-mapped files (posix), queues (data-structures),
diff --git a/batch-driver.scm b/batch-driver.scm
index 31de335..514022d 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -225,9 +225,8 @@
(upap #f)
(ssize (or (memq 'nursery options) (memq 'stack-size options)))
(module-name
- (cond ((memq 'module options) => option-arg)
- ((memq 'main-module options) "main")
- (else #f))))
+ (and-let* ((m (memq 'module options)))
+ (option-arg m))))
(define (cputime) (current-milliseconds))
diff --git a/c-platform.scm b/c-platform.scm
index 4089dc7..f30e1d1 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -95,7 +95,7 @@
compile-syntax tag-pointers accumulate-profile
disable-stack-overflow-checks raw specialize
emit-external-prototypes-first release local inline-global
- analyze-only dynamic main-module
+ analyze-only dynamic
no-argc-checks no-procedure-checks no-parentheses-synonyms
no-procedure-checks-for-toplevel-bindings
no-bound-checks no-procedure-checks-for-usual-bindings no-compiler-syntax
diff --git a/csc.scm b/csc.scm
index 243cfdc..8b8e1b5 100644
--- a/csc.scm
+++ b/csc.scm
@@ -147,7 +147,6 @@
-check-syntax -case-insensitive -shared -compile-syntax -no-lambda-info
-dynamic -disable-stack-overflow-checks -local
-emit-external-prototypes-first -inline -release
- -main-module
-analyze-only -keep-shadowed-macros -inline-global -ignore-repository
-no-symbol-escape -no-parentheses-synonyms -r5rs-syntax
-no-argc-checks -no-bound-checks -no-procedure-checks -no-compiler-syntax
@@ -171,7 +170,6 @@
'((-h "-help")
(-s "-shared")
(-m "-module")
- (-M "-main-module")
(|-P| "-check-syntax")
(-f "-fixnum-arithmetic")
(|-D| "-feature")
@@ -361,7 +359,6 @@ Usage: #{csc} FILENAME | OPTION ...
-no-module-registration do not generate module registration code
-no-compiler-syntax disable expansion of compiler-macros
-m -module NAME wrap compiled code in a module
- -M -main-module wrap compiled code in a module called "main"
Translation options:
diff --git a/manual/Using the compiler b/manual/Using the compiler
index e57ffca..79b53c0 100644
--- a/manual/Using the compiler
+++ b/manual/Using the compiler
@@ -90,8 +90,6 @@ the source text should be read from standard input.
; -lfa2 : Does an additional lightweight flow-analysis pass on the fully optimized program to remove more type checks.
-; -main-module : wraps the compiled code in an implicit module named {{main}}, importing the {{scheme}} and {{chicken}} modules.
-
; -module NAME : wraps the compiled code in an implicit module of the given {{NAME}}, importing the {{scheme}} and {{chicken}} modules.
; -no-argc-checks : disable argument count checks
diff --git a/support.scm b/support.scm
index 15d1745..7553743 100644
--- a/support.scm
+++ b/support.scm
@@ -1654,7 +1654,6 @@ Usage: chicken FILENAME OPTION ...
-no-module-registration do not generate module registration code
-no-compiler-syntax disable expansion of compiler-macros
-module NAME wrap compiled code in a module
- -main-module wrap compiled code in a module called "main"
Translation options:
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 408076d..9511ca5 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -335,13 +335,9 @@ echo ======================================== module tests (command line options
set module="test"
%compile% test.scm -w -A -j %module% -module %module%
if errorlevel 1 exit /b 1
-%compile% test.scm -w -A -j main -main-module
-if errorlevel 1 exit /b 1
%interpret% -e "(import %module%)"
if errorlevel 1 exit /b 1
-%interpret% -e "(import main)"
-if errorlevel 1 exit /b 1
-del /f /q %module%.import.scm main.import.scm
+del /f /q %module%.import.scm
echo ======================================== module tests (compiled) ...
%compile% module-tests-compiled.scm
diff --git a/tests/runtests.sh b/tests/runtests.sh
index d366fd9..05d6c42 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -287,10 +287,8 @@ $interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm
echo "======================================== module tests (command line options) ..."
module="test-$(date +%s)"
$compile test.scm -A -w -j "$module" -module "$module"
-$compile test.scm -A -w -j main -main-module
$interpret -e "(import $module)"
-$interpret -e "(import main)"
-rm -f "$module.import.scm" main.import.scm
+rm -f "$module.import.scm"
echo "======================================== module tests (compiled) ..."
$compile module-tests-compiled.scm
--
2.6.1
_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers