Documentation
Not logged in

Copyright (C) 2009-2010, Trevor Davel <twylite AT crypt DOT co DOT za>
See the file "LICENSE.txt" (Tcl/Tk License) for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.


Navigation: control::functional manual | TIP: Higher-order functions in Tcl.

control::functional - Introduction, Motivation and Goals

Introduction & Motivation

Functional programming is becoming more widely used in industry. It has been popularised by high-availability telecoms systems (Ericsson's Erlang) and the application of functional concepts to scalability (e.g. Google's mapreduce), and is spurred on by success stories from large web site (like Facebook).

New languages with strong support for the functional paradigm - Scala, Clojure, F# - are gaining mindshare on developer sites. Javascript frameworks, in particular those supporting AJAX, have brought more developers into contact with first-class functions. Non-functional languages like Java and C# have support for anonymous functions and higher-order operations.

Tcl does not "have" higher-order functions, but it supports functional concepts in its own way:

There are also extensions that provide well-known higher-order functions such as those mentioned above: Tcllib's struct::list, Wub's functional-1.0.tm, and NEM's More functional programming (aka 'funtcl') are the most widely known.

Still, Tcl does not "have" higher-order functions, in the same way that Tcl 8.4 did not "have" OO. And Tcl needs higher-order functions for much the same reasons that it needed OO:

  1. A common base system to promote reuse.
  2. Prevent authors from reinventing the wheel (poorly).
  3. Stop ill-informed criticism that Tcl doesn't support functional programming (or at least higher-order functions).
  4. Performance gains can be made by C and bytecoded implementations.

Design goals

Enhancements to Tcl's support for functional programming should probably meet the following goals: