A few sugestions:
1 -- The manual says:
32.4.2 Stack allocation
*When the -fstack flag is enabled, the compiler may automatically replace
some heap allocations with stack allocations.*
It seems that this option does not exist anymore.
2 -- Common Lisp and Chez Scheme have an incremental compiler, then
interpreted code is as fast as compiled code. In Bigloo and Gambit, the
interpreter is slow, but one can load dynamic libraries into the
interpreter, which solves the problem. However, it would be fine if there
were a function called compile-file, that could compile and load a dynamic
library. Here is a proof of concept:
*;; compile-file ;proof of concept(define cmd "bigloo -dload-sym
-export-all -y ~a.scm")(define bench "bigloo -dload-sym -export-all
-Obench -y ~a.scm")(define (compile-file fname #!optional (opt cmd)) (let*
[ (dynafile (format "./~a.so" fname))] (system (format opt fname))
(dynamic-load dynafile)))(define (tm fn) (multiple-value-bind (res t1 t2
t3) (time fn) (list res (/ t1 1000.0) (/ t2 1000.0)
(/ t3 1000.0)) ))(define (del fname) (system (format "rm
./~a.so ./~a.o" fname fname)))*
Here is how to use it:
1:=> (load "cfile.scm")
1:=> cmd
bench
compile-file
tm
del
cfile.scm
1:=> (compile-file "fib" bench)
1:=> 8
#<output_port:stdout>
1:=> (tm (delay (fib 40)))
1:=> (165580141 0.34 0.0 0.34)
3 -- The problem with the program above is that one cannot redefine
functions:
*1:=> (compile-file "fib")1:=> #unspecified1:=> (tm (delay (fib 40)))1:=>
(165580141 0.34 0.0 0.34)*
1:=> (define fib 42)
1:=>
File "stdin", line 6, character 111:
#(define fib 42)
#^
*** ERROR:set!
read-only variable -- fib
Therefore, it is not possible to develop programs interactively. In gambit,
I can redefine compiled functions. Even when people are using the
interpreter to test concepts, they often need fast execution, so it is
necessary to have a tool such as compile-file.