PLT-scheme - Supplementary PLT Scheme 1 Purpose and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Supplementary: PLT Scheme 1 Purpose and background This document covers some features of PLT Scheme for CS 136 students interested in going be- yond what is covered in lecture. It can be read at any time during the course or afterwards, but some topics may assume preparation from certain CS 136 lectures. It assumes that stu- dents know the basics of the dialects of Scheme known as the “teaching languages” from CS 135 and the How To Design Programs textbook ( ). Other useful ref- erences include the Guide and Reference in DrScheme’s Help Desk, the R5RS (Scheme stan- dard) document (in DrScheme’s Help Desk or ), the SRFI docu- ments describing standard libraries (in Help Desk, or ) and the book The Scheme Programming Language (TSPL), by Kent Dybvig (available in paperback or at ). 2 PLT Scheme v4 PLT Scheme is R5RS plus many useful extensions. The starting point for use of the full language is to choose the Module language in DrScheme, and to make sure that the following line is the first line of the program. #lang scheme This is “syntactic sugar” that wraps the entire file in a module declaration and loads all bindings for the full PLT Scheme language. There are other options for the first line. For example, using scheme/base instead of scheme loads a smaller “core” language. A module is a way of packaging code to control what bindings are imported and exported. (provide my-fn1 ...) (require "") module bindings If the program is saved in , then the #lang scheme line is equivalent to ( module myfile scheme ...) The program can then be run on the command line in the following fashion: mzscheme mzscheme is included with the DrScheme distribution, but you may need to set up your shell so that its search path includes the directory it is in (or an alias to it). This is particularly convenient for testing that involves I/O, as file redirection can be used. 1 There are many optional command-line flags for mzscheme , including one which gives you a basic read-evaluate-print loop (REPL) after running your program. See the PLT Scheme documen- tation for more details. Any additional command-line arguments are put into a vector (see below) that is the value of the expression ( current-command-line-arguments ). 3 Conditionals The basic conditional construct used in CS 135 is cond , which is in standard Scheme. In R5RS, cond is built on top of if using a macro (macros are described in a later section). ( if test true-exp false-exp ) evaluates test and, depending on its value, evaluates either true-exp or false-exp . PLT Scheme also provides one-armed versions of if called when and unless ....
View Full Document

This note was uploaded on 10/21/2010 for the course CS 136 taught by Professor Becker during the Winter '08 term at Waterloo.

Page1 / 12

PLT-scheme - Supplementary PLT Scheme 1 Purpose and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online