Global Variables

A global variable is a variable that can be accessed by all functions.

A global variable can be established by define:


   (define *turtle-pen* #f)
The define establishes the variable as global and gives it an initial value.

Global variables can cause certain problems:

Rule: Enclose global variable names in *, both as documentation and to avoid name conflicts.

Rule: Use global variables sparingly (never on exams).

Contents    Page-10    Prev    Next    Page+10    Index