The Java Language Specification
The Java Language Specification
The Lambda library: unnamed functions in C++
Software—Practice & Experience
Functional programming with the FC++ library
Journal of Functional Programming
Concepts: linguistic support for generic programming in C++
Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications
Proceedings of the 2007 ACM symposium on Applied computing
Hybrid bulk synchronous parallelism library for clustered smp architectures
Proceedings of the fourth international workshop on High-level parallel programming and applications
Hi-index | 0.00 |
A "functional" style of programming has become common in C++, following the introduction of the "Standard Template Library" (STL) into C++'s standard library. C++ is, however, notably lacking in its support for this style and thus cannot take full advantage of its own standard libraries. C++'s mechanisms for defining functions or objects to pass to STL algorithms are overly verbose. The effective use of modern C++ libraries calls for lambda functions in the language. This paper describes a design and implementation of built-in lambda functions for C++. C++'s compilation model, where activation records are maintained in a stack, and the lack of automatic object lifetime management, make safe lambda functions and closures challenging: if a closure outlives its scope of definition, references stored in a closure dangle. Our design is careful to balance between conciseness of syntax and explicit annotations to guarantee safety. Lambda functions can be declared without annotating their parameter types. C++0x, the forthcoming revision of standard C++, supports constrained templates and modular type checking. We describe how to infer parameter types of lambda functions from the constraints of generic functions in order to support modular type checking in the presence of lambda functions. Our design is currently under consideration for adoption to C++0x.