Intro
Outline
Goals of Closures
Definition
Control Abstraction APIs
Example: For-Each - 1
Example: For-Each - 2
Example: For-Each - 3
Example: For-Each - 4
Example: For-Each - 5
Example: For-Each - 6
Anonymous Instances
Program to be refactored
Program refactored - 1
Program refactored - 2
An app-specific example: time - 1
An app-specific example: time - 2
Requirements for Closures
Closures: the specification
Syntax: Function Types - 1
Syntax: Function Types - 2
Semantics: Function Types - 1
Semantics: Function Types - 2
Syntax: Closures - 1
Syntax: Closures - 2
Semantics: Closures - 1
Semantics: Closures - 2
Syntax: Control Invocation - 1
Syntax: Control Invocation - 2
Syntax: Control Invocation - 3
Example: Control Abstractions - 1
Example: Control Abstractions - 2
Example: Control Abstractions - 3
Example: Aggregate Operations
Example: Interaction w/ Existing APIs - 1
Example: Interaction w/ Existing APIs - 2
Example: Interaction w/ Existing APIs - 3
Example: Interaction w/ Existing APIs - 4
Example: Interaction w/ Existing APIs - 5
Example: Interaction w/ Existing APIs - 6
New APIs
Map-specific iteration
Locking
Closing Streams
Aggregate Operations
More complex APIs
References
Thank You
We have proposed to add Closures to the Java Programming Language. Closures simplify the use of APIs that rely on the use of anonymous class instances, such as the concurrency APIs and callbacks. More importantly, closures support control abstractions, which are APIs that act as programmer-defined control constructs.
This JavaPolis talk describes the proposed language extension and its design rationale, and shows how it will affect existing and future APIs.
Neal Gafter is a software engineer and Java evangelist at Google. He was previously a senior staff engineer at Sun Microsystems, where he designed and implemented the Java language features in releases 1.4 through 5.0. Neal is coauthor of "Java Puzzlers: Traps, Pitfalls, and Corner Cases" (Addison Wesley, 2005). He was a member of the C++ Standards Committee and led the development of C and C++ compilers at Sun Microsystems, Microtec Research, and Texas Instruments. He holds a Ph.D. in computer science from the University of Rochester.