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

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

[MIT-Scheme-devel] How to run a script and exit?


From: SB
Subject: [MIT-Scheme-devel] How to run a script and exit?
Date: Mon, 9 Sep 2019 01:16:19 +0800

How can I run a Scheme script and exit? For example, if I have a file named 'myscript.scm` containing:

    (display "Hello!")
    (newline)
    (display (+ (read) 1))

How can I run the file using MIT Scheme?

Contrary to the convention in just about every other programming language implementation, `mit-scheme myscript.scm` is not valid on the command line.

There have been fairly popular questions of Stack Overflow about this problem:

* https://stackoverflow.com/questions/903968/how-do-i-execute-a-scm-script-outside-of-the-repl-with-mit-scheme
* https://stackoverflow.com/questions/24720112/mit-scheme-run-a-script-and-exit
* https://stackoverflow.com/questions/39816824/how-do-you-use-mit-gnu-scheme-in-non-repl-mode

Most of the "solutions" involve input redirection ('mit-scheme --quiet < myscript.scm`), but this method fails when the script uses input procedures (e.g. read, read-char, read-line. etc.) because the input redirection causes the input procedures to read from the file rather than prompt the user for input.

Is there a way to run a Scheme script using MIT Scheme? If so, how?

reply via email to

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