Designing Abstractions with First-Class Functions

external ~<#71376#>This section requires <#65573#><#29645#>local<#29645#>-expression<#65573#>s: see intermezzo~#secintlocal#29646>. Learning to function with first-class functions is critical for all aspects of GUI programming. All GUIs, including Java AWT-based ones, use functions as values, though they are called objects in that world.<#71376#> We have seen that functions can consume functions and how important that is for creating single points of control in a function. But functions cannot only consume functions, they can also <#29647#> produce<#29647#> them. More precisely, expressions in the new Scheme can evaluate to functions. Because the body of a function definition is also an expression, a function can produce a function. In this section, we first discuss this surprising idea and then show how it is useful for abstracting functions and in other contexts.