Skip to main content
USENIX
  • Conferences
  • Students
Sign in

connect with us


  •  Twitter
  •  Facebook
  •  LinkedIn
  •  Google+
  •  YouTube

twitter

Tweets by @usenix

usenix conference policies

  • Event Code of Conduct
  • Conference Network Policy
  • Statement on Environmental Responsibility Policy

You are here

Home ยป A Framework for Higher-Order Functions in C++
Tweet

connect with us

A Framework for Higher-Order Functions in C++

Authors: 

Konstantin Laufer, Loyola University of Chicago

Abstract: 

C and C++ allow passing functions as arguments to other functions in the form of function pointers. However, since function pointers can refer only to existing functions declared at global or file scope, these function arguments cannot capture local environments. This leads to the common misconception that C and C++ do not support function closures. In fact, function closures can be modeled directly in C++ by enclosing a function inside an object such that the local environment is captured by data members of the object. This idiom is described in advanced C++ texts and is used, for example, to implement callbacks. The purpose of this paper is twofold: First, we demonstrate how this idiom can be generalized to a type-safe framework of C++ class templates for higher-order functions that support composition and partial application. Second, we explore the expressiveness of the framework and compare it with that of existing functional programming languages. We illustrate by means of various examples that object-oriented and functional idioms can coexist productively and can be used to enhance the functionality of common classes, for example, of nonlinear collections such as trees. A C++ implementation of the framework is available on request.

Konstantin Laufer, Loyola University of Chicago

BibTeX
@inproceedings {260440,
author = {Konstantin Laufer},
title = {A Framework for {Higher-Order} Functions in C++},
booktitle = {USENIX Conference on Object-Oriented Technologies (COOTS 95)},
year = {1995},
address = {Monterey, CA},
url = {https://www.usenix.org/conference/coots-95/framework-higher-order-functions-c},
publisher = {USENIX Association},
month = jun
}
Download

Links

Paper: 
http://usenix.org/publications/library/proceedings/coots95/full_papers/laufer.ps
  • Log in or    Register to post comments

© USENIX

  • Privacy Policy
  • Contact Us