Forester 4.2 › First-class functions and lazy arguments [00YF]

This release adds λ-abstraction, which can be written like so:

\fun[x][y]{Hello, \x and \y}

In addition, lazy arguments are now supported. In any place that a function argument can be bound (e.g. in \def, \let, or \fun), an argument marked with a tilde is automatically wrapped in a thunk when it is passed. For example, consider the following code:

\def\my-fun[x][~y]{Hello, \x and \y{}!}

\p{\my-fun{foo}{bar}}

In the above, the argument x is strict and y is a thunk that must be forced before being used—hence the application to {}; note that the results are not memoised. The code above is functionally equivalent to the following:

\def\my-fun[x][y]{Hello, \x and \y{}!}

\p{\my-fun{foo}{\fun[z]{bar}}}

Of course, when your code is pure, passing by name vs. by value does not make a difference. The purpose of this feature is, however, to enable more expressive macros that make use of fluid bindings.

Context

Release. Forester 4.2 [00WK]

Backlinks

Forester 4.2 › New query language › Unions and intersections of families of queries [00X1]