Script semantics and declarations Lassi Kortela 28 Jun 2021 06:59 UTC

Two suggestions:

1. I think we need a particular mindset shift to keep the complexity
under control, and that shift is to let go of the idea of shipping the
launcher with any Scheme implementation. It should be a separate program
(a very light and portable C program that is trivial to install from
`apt-get` and the like).

To be sure, we can and should specify the semantics of the launcher in a
SRFI in case people want to make alternative implementations of it, but
I wouldn't really encourage that each Scheme have its own.

2. Instead of fixing precise semantics for the execution a script, I
would suggest the following approach:

- Parse declarations from an S-expression in a standard format.

- Those could look like this (all details subject to debate):

(declare-file
   (language r7rs))

in which case the launcher passes the script to any R7RS implementation
it can find (adding the right command line flags, e.g. `gsi-script
-:r7rs` for Gambit, and `gosh -r 7` for Gauche).

Similarly, one can write:

(declare-file
   (language r6rs))

in which case the launcher could use `sagittarius -r 6` or `larceny
-r6rs` or `mosh` for example.

If the script is only known to work in particular Scheme
implementation(s), one could use:

(declare-file
   (language scheme)
   (implementation gambit gauche))

in which case the launcher runs `gsi-script` with no `-:r7rs` flag, or
`gosh` with no `-r 7` flag.

Or:

(declare-file
   (language r7rs)
   (implementation chibi gauche gambit))

in which case it runs `chibi` or `gosh -r 7` or `gsi-script -:r7rs`. In
case none of those implementations are installed, it gives up, since the
script hasn't given it permission to try other implementations.

These declarations can be extended outside of Scheme, to also work with
other Lisp dialects and implementations. I have working code to use it
with Common Lisp, Emacs Lisp, and Clojure. For example:

(declare-file
   (language common-lisp)
   (implementations sbcl ccl clisp))

Examples here: https://github.com/lispunion/lila/tree/master/examples