Version 5 of Higher order TIP discuss

Updated 2010-04-15 23:12:15 by Twylite

Discussion page for [L1 ], a proposal for Higher Order Functions in Tcl that is intended to result in a TIP.


escargo 15 Apr 2010 - There appears to be some damage to the page in the reference link. One heading is tr;dr. Headings for "Introduction, Motivation and Goals," "A review of FP and higher order functions in Tcl," and "The design of this proposal" appear to be missing.

One feature of the design of the proposal is described like this:

filter predicate list is a filter over a list, and predicate is a cmdprefix that must return a boolean.

This is somewhat imprecise in that Tcl does not have a boolean data type. More firmly specified would be to say that cmdprefix must return 0 or 1.

The discussion about optional arguments would be clarified if the distinction between formal arguments and actual arguments were more clearly drawn.

While proponents of functional programming might know about left fold and right fold an explanatory reference for the rest of us would be welcome.

[Twylite] 2010/04/16: No damage; the "missing" headings are external links. I have updated the doc to make this more readily apparent (I hope).

The concept of a "boolean" is defined in the man page for if - I have updated the doc to refer to this definition.

Thanks for the comments on the "optional arguments" proposal. I will improve this proposal in time; it will not form part of the Higher Order Functions TIP and should probably be a TIP in its own right. The idea is rather rough at the moment but I wanted to get it down and hear some opinions.

The tl;dr is deliberately brief, take a look at the manual (link is now more obvious, in the ToC) for more detail and a link to the Wikipedia.


Lars H: While I certainly agree with the proposal's philosophy that a command prefix should be considered the normal Tcl equivalent of an abstract function, I'm somewhat at a loss as to what the TIP is supposed to actually propose. The whole thing just looks like a collection of observations.

[Twylite] 2010/04/16 Fair point. The TIP will do two things:

  1. Present a consistent model for handling functions, and propose that future TIPs (that accept or return command prefixes or functions) conform to (or at least interoperate with) this model.
  2. Propose the inclusion in the Tcl core of the following commands: lambda, lamdaexpr, curry, compose, foldl, foldr, filter, map, range.

The doc has been updated to indicate this (at the top of the tl;dr).

The rationale for including these commands in the core is given in the Introduction, Motivation and Goals section.