Welcome
Why Add Closures?
Outline - Goals, Definitions
Goals
Definition: Closure
Definition: Control API
Outline - Existing Solutions
For-Each: Using anonymous instances
For-Each: Desired - Actual - 1
For-Each: Using anonymous instances
For-Each: Desired - Actual - 1
For-Each: Desired - Actual - 2
For-Each: Desired - Actual - 3
For-Each: Desired - Actual - 4
For-Each: Desired - Actual - 5
Anonymous Instances
Outline - Requirements
Program To Be Refactored
Program Refactored - 1
Program Refactored - 2
App-Specific Example: Time - 1
App-Specific Example: Time - 2
App-Specific Example: Time - 1
App-Specific Example: Time - 2
Requirements for Closures
Outline - Specification
Closures Specification
Syntax: Closure Expressions - 1
Syntax: Closure Expressions - 2
Semantics: Closure Expressions - 1
Semantics: Closure Expressions - 2
Syntax: Function Types - 1
Syntax: Function Types - 2
Semantics: Function Types - 1
Semantics: Function Types - 2
Syntax: Control Statements - 1
Syntax: Control Statements - 2
Syntax: Control Statements - 3
Outline - Examples
Example: java.util.concurrent.Lock (today)
proposed new closure-based API
Using the control statement syntax
Example: Aggregate Operations
using an Executor (today)
using an Executor (closure)
Example: Interaction With Existing APIs
Add a swing listener (today)
Add a swing listener (closure)
using the control statement syntax
Outline - New APIs
New APIs
Map-Specific Iteration
Locking
Closing Streams
Aggregate Operations
More complex APIs
For More Information
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 2nd closures talk includes some new ideas on the subject.
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.