11
votes

I have searched and I really can't seem to find this really basic question. I am new to mit-scheme and essentially I want to recreate hello world but instead of doing it through the prompt, I want to have a scheme file that contains the following code:

 (define hello-world
 (lambda ()
     (begin
        (write 'Hello-World)
        (newline)
        (hello-world))))

The problem is I am missing the simplest questions: What is the file extension for a scheme file? How do I run that file through scheme?

I have tried .ss and .scm but every time I try scheme hello-world.scm it says:

;Warning: Invalid keyword: "hello-world.scm"

;Warning: Unhandled command line options: ("hello-world.scm")
3

3 Answers

15
votes

Your issue isn't the file extension, it's just that MIT Scheme prints an error if invoked as scheme hello-world.scm, since it's supposed to be invoked as

scheme --load hello-world.scm

Also, note that you are using a left-quote character rather than the actual quote character '. If you look closely you can see the difference.

9
votes

Start the scheme interpreter in the same directory as your file. Once you are in the interpreter of mit-scheme, you can always use the following procedure which is built into scheme:

(load "file-name.extension")

This will load the file into scheme. I hope that helped :)

0
votes

If you are using Visual Studio Code as an editor, you may want to use the "Code Runner extension"
make sure it's installed from the vs code marketplace
then enter Preferences: Open Settings (JSON) and past the following:

"code-runner.executorMap": {
        "scheme": "(exit); racket -i -e '(enter! \"$fileName\")'",
    },

You will be able to run directly your file by clicking the Run Code icon or by pressing Ctrl+Alt+N

NB: putting #lang racket in the top of your file is necessary