|
Several comments
shivers@xxxxxx
(10 Mar 2001 02:57 UTC)
|
|
Re: Several comments
Per Bothner
(10 Mar 2001 03:48 UTC)
|
|
Re: Several comments
sperber@xxxxxx
(10 Mar 2001 08:50 UTC)
|
|
Re: Several comments
shivers@xxxxxx
(10 Mar 2001 17:23 UTC)
|
|
Re: Several comments
Martin Gasbichler
(11 Mar 2001 14:31 UTC)
|
|
Re: Several comments
Marc Feeley
(20 Mar 2001 16:14 UTC)
|
|
Re: Several comments
sperber@xxxxxx
(20 Mar 2001 16:33 UTC)
|
|
Re: Several comments
Marc Feeley
(20 Mar 2001 17:11 UTC)
|
|
Re: Several comments
sperber@xxxxxx
(22 Mar 2001 08:27 UTC)
|
|
Re: Several comments
Marc Feeley
(22 Mar 2001 13:05 UTC)
|
|
Re: Several comments
sperber@xxxxxx
(22 Mar 2001 13:29 UTC)
|
|
Re: Several comments Marc Feeley (22 Mar 2001 15:06 UTC)
|
|
Re: Several comments
sperber@xxxxxx
(22 Mar 2001 15:11 UTC)
|
|
Re: Several comments
Marc Feeley
(22 Mar 2001 15:28 UTC)
|
|
Re: Several comments
Per Bothner
(22 Mar 2001 17:01 UTC)
|
|
Re: Several comments
Marc Feeley
(22 Mar 2001 18:22 UTC)
|
> 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