Music 220b: Winter 2001
Fernando Lopez-Lezcano, instructor
Christopher Burns, teaching assistant
Tamara Smyth, teaching assistant

Week 2: variables

Lisp, like other programming languages, relies heavily upon the use of variables. Variables come in two types: global and local. An example of a global variable is CLM's *srate*: any CLM function might need to know what the current sampling rate is, and so the variable is available across the lisp environment. Local variables, by contrast, are only defined and usable within a limited scope. For instance, we might write two different instruments, each of which has a variable called pitch-envelope. If we make these variables local within the instruments, we can set each to a unique value without its influencing the other.

Good programming style dictates that we use local variables whenever possible; this minimizes the possibility of conflicts with other programs (including our own).

Course resources main page
220b main page