Lecture overview -- Keyboard shortcut: 'u'  Previous page: Closures revisited [Section] -- Keyboard shortcut: 'p'  Next page: Classes and objects in Scheme [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 8 - Page 2 : 11
Functional Programming in Scheme
Object-oriented programming in Scheme
Functions and closures

On this page we review some of the properties of function object - also known as closures. The contents of this pages is taken directly from an earlier pages in this material.

A function object represents a function at run time. A function object is created as the value of a lambda expression

A function object is also known as a closure.

A function object is a first class value at run time, in the same way as numbers, lists and other data are values. This is different from more traditional programming languages, where procedural and functional abstractions have another status than ordinary data.

The name 'closure' is related to the interpretation of free names in the body expression of the function. Free names are used, but not defined in the body. In a function object (or closure) the free names are bound in the context of the lambda expression. This is a contrast to the case where the free names are bound in the context of the application of the function.

  • Characteristics of function objects:

    • First class objects

    • Does not necessarily have a name

    • A function object can be bound to a name in a definition

    • Functions as closures:

      • Capturing of free names in the context of the lambda expression

      • Static binding of free names

      • A closure is represented as a pair of function syntax and values of free names

    • A function object can be applied on actual parameters, passed as a parameter to a function, returned as the result from another function, and organized as a constituent of a data structure