[gambit-list] How to create small standalone executable with

Marc Feeley feeley at iro.umontreal.ca
Mon Aug 17 09:35:04 EDT 2009


On 17-Aug-09, at 7:45 AM, David Bridgham wrote:

> Adrien Piérard wrote:
>
>> This is quite hard, because in Scheme, you may call a function which
>> does not appear in the source code.
>> For example, the code below uses the function "LOAD", but there is no
>> way you can forsee that…
>> This is not a problem of Gambit-C, it's a feature of Scheme (and  
>> other
>> languages with an EVAL function)
>>
>> (define func "lo")
>> (define tion "ad")
>> (eval (list (string->symbol (string-append func tion)) "another- 
>> file.scm"))
>>
>
> Sure.  If you call eval then everything else has to get dragged in.   
> If
> you don't call eval, why does the entire library get linked in rather
> than only what's called?

Tree-shaking in a Lisp-like language is not easy...

 > (##global-var-ref (##make-global-var (string->symbol (string-append  
"ev" "al"))))
#<procedure #2 eval>

Also, understand that something as "simple" as the call (write  
"hello") is not so simple.  The write procedure needs lots of runtime  
support procedures to do its work.  For example, write uses hash  
tables to detect circular structures, it uses most of the I/O  
infrastructure including the Unicode character encoding support, it  
uses string ports for handling the special case (write (list 'unquote  
'@foo)), etc.

Moreover, Gambit was designed to support live debugging.  I view live  
debugging as one of the most important legacies of Lisp.  If the  
(write "hello") call encounters an error (such as "disk full") then  
the debugger will be invoked to allow the programmer to understand and  
fix the problem.  Gambit's debugger is a REPL where you can evaluate  
any expression.  So you need to have "eval", "load", and all the rest  
of the Gambit runtime system available.

Notice also that you can setup Gambit so that the runtime library will  
be a shared library roughly 3MB big.  A "hello world" program will be  
a few kB.  The Gambit library is mostly self contained.  It needs the  
C library (for basic things like malloc and sqrt and very little else)  
so the total "size" of the runtime is actually much less than for a  
language like Java.

If you wish to try to get a minimal runtime system for Gambit, check:

https://webmail.iro.umontreal.ca/pipermail/gambit-list/2008-October/002725.html

Marc




More information about the Gambit-list mailing list