mit-scheme-users
[Top][All Lists]
Advanced

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

Re: [MIT-Scheme-users] Adding command-line processing to my script


From: Matt Birkholz
Subject: Re: [MIT-Scheme-users] Adding command-line processing to my script
Date: Wed, 10 Dec 2014 11:15:46 -0700

> From: Nathan Thern <address@hidden>
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]