Works!
The "command-line" procedure and the -- separator don't appear to be
documented - are they new? Also, is there a way to use #! notation in a
script?
After trying hard to understand the docs better, I think that the way
one would use "argument-command-line-parser" is via "load" and
"disk-save" and then calling mit-scheme with the --band argument. Is
that right? (I haven't tried it; this is more for curiosity's sake
because I don't think I would do things that way.)
On 12/10/2014 1:15 PM, Matt Birkholz wrote:
From: Nathan Thern <nth...@gmail.com>
Date: Tue, 9 Dec 2014 16:55:48 -0500
I should mention that I also tried adding a dash ("calc" => "-calc")
in the "argument-command-line-parser" line:
(argument-command-line-parser "-calc" #f calc)
Same error.
By the time your script installs your command line parser, the command
line has already been parsed.
If you separate the machine options from your script's options with
"--" you will not get the warning. The command-line procedure will
return the words following "--" as a list of strings.
Compiling scripts is not recommended. You probably want to do
something like the following.
cat >fib-script.scm <<EOF
(load "fib-program.com")
(let ((words (command-line)))
(if (not (= (length words) 1))
(error "One integer argument is required..."))
(let* ((n-str (car words))
(n (string->number n-str))
(fib-n-str (number->string (fib n))))
(display (string-append n-str"th Fibonacci number is "fib-n-str"\n"))))
(%exit)
EOF
cat >fib-program.scm <<EOF
(declare (usual-integrations))
(define (fib m)
(if (< m 2)
m
(+ (fib (- m 1)) (fib (- m 2)))))
EOF
mit-scheme <<EOF
(compile-file "fib-program")
EOF
mit-scheme --batch-mode --load fib-script -- 10
_______________________________________________
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users