This page is part of the web mail archives of SRFI 22 from before July 7th, 2015. The new archives for SRFI 22 contain all messages, not just those from before July 7th, 2015.
> Marc> and "scheme-script" would always invoke "script-main" after loading a > Marc> script. > > I can imagine going with that. Opinions, anyone else? Can you explain your position on the other alternatives. In particular the second one which is my preference: #! /bin/sh "exec" "scheme-script" "$0" "$@" (define (main arg1 arg2) (write (+ (string->number arg1) (string->number arg2)))) (apply main (script-arguments)) I forgot to mention that it allows scripts to be compiled to an executable program (i.e. a.out), as well as to a "fasl" file. For this to work, "script-arguments" behaves as follows depending on the context: 1) In the dynamic extent of a "load": (script-arguments) signals the error "Attempt to load a script in an inappropriate context". This happens whether the file loaded is a source code file or a "fasl" file. 2) In all other contexts, and in particular during loading as a script by scheme-script and during the execution of a compiled program: (script-arguments) returns the command line arguments as a list of strings. For example, the above script could be compiled with Gambit to an "a.out" simply with: % gsc S.scm % gcc S.c S_.c -lgambc % a.out 100 200 There is no need for the compiler to know that it is compiling a script. My third alternative, based on the implicit call of a "script-main" procedure, requires the compiler to know it is compiling a script so it has to be given a special compilation option, or detect that the file being compiled starts with "#!" (actually it is a bit more complicated because it is the linker that has to know it is generating an executable and one of the source files was a script). Marc