Lecture overview -- Keyboard shortcut: 'u'  Previous page: Definitions [Section] -- Keyboard shortcut: 'p'  Next page: Functions [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 31 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Definitions

A definition binds a name to a value


(define name expression)

A name is first introduced and the name is bound to the value of the expression

  • About Scheme define forms

    • Appears normally at top level in a program

    • Creates a new location named name and binds the value of expression to that location

    • In case the location already exists we have a redefinition, and the define form is equivalent to the assignment (set! name expr)

    • Does not allow for imperative programming, because define cannot appear in selections, iterations, etc.

    • Can also appear at certain positions in bodies, but only as syntactic sugar for local binding forms (letrec)