[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] command-line and invocation manner



On Thu, Sep 19, 2013 at 3:48 AM, Per Bothner <per@x> wrote:
The command-line procedure doesn't distinguish between what we
might call "application arguments" (arguments meant for the
application) and "invocation arguments" (the command and argument
for starting up Scheme with a given "application").

Yes, this isn't specified clearly so I think implementations
have some leeway here.

There are two things you might want to use the application
arguments for: 1) logging, so users know what program an
error came from, and 2) reconstructing the command line
for re-execution.

For native compiled programs the application arguments
are always just the program name, and there's nothing to
decide.

For SRFI-22 or other shebang scripts, for use 1) you want
just the script name.  For use 2) just the script name will
also do the right thing.  This is what chibi-scheme does.

One might load this file using load, run it from the command line,
or compile it and then execute it.  I think one would want the application
arguments to be the same regardless.  The choice I made for Kawa
was that the application arguments are (cdr (command-line))
while the invocation arguments are pasted to a single string as
the (car (command-line)).  I think this is allowed by R6RS/R7RS,
and I think this is a reasonable approach.

Examples:

$ java kawa.repl ~/tmp/foo.scm abc "def ghi"
c-l: ("java kawa.repl /home/bothner/tmp/foo.scm" "abc" "def ghi")

Here kawa doesn't fall into either case (native or shebang
script) above.  I think your approach may be the most
reasonable.  It won't be portable, and may trip up people
not expecting this, but then launching Scheme via Java
modules supplied on the command-line can't be portable
anyway.

Compiling to an application (with a static "main" method):

$ kawa --main -C ~/tmp/foo.scm
(compiling /home/bothner/tmp/foo.scm to foo)
$ java foo abc "def ghi"
c-l: ("java foo" "abc" "def ghi")

I guess if the OS supports natively running compiled Java
then this would just be runnable as:

$ foo abc "def ghi"
c-l: ("foo" "abc" "def ghi")

as in other compiled implementations?

-- 
Alex

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports