Scheme Programming/Using a Scheme interpreter

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Scheme Programming
 ← What defines Scheme? Using a Scheme interpreter A taste of Scheme → 

On most Unix machines, 'scm' can be installed. This is a Scheme interpreter which adheres to R5RS very well.

To invoke the interpreter, simply type 'scm' at the command line. It is common to write your programs into a text file using Vim or emacs, and then load them in using the 'load command':

$ scm
> (load "myFile.scm")

Windows users have a number of options for getting a standards-conforming Scheme implementation. Both PLT Scheme/Racket and MIT/GNU Scheme will work. (However, keep in mind that Racket implements its own version of the language, with considerable changes in syntax).

There are a great many Scheme systems available for use, and, unfortunately, they can all behave quite differently. Portability for Scheme programs written using non-standard features are rare, so often the correctness of one's code will vary depending on the compiler or interpreter used. For this reason, when maximum portability is desired, it is wise to write all code in R5RS, as this is the most widely implemented standard. (R6RS has elicited controversy from some).

REPL bookmarklet[edit | edit source]

The look of the REPL on this page

While reading this book you can use bookmarklet that will create Scheme REPL directly on this wiki book, the link to bookmarklet can be found at LIPS Scheme website. You will need to run this bookmark on each page you visit, because it will be gone, after you navigate to different page.