O'Reilly logo

Domain Specific Languages by Martin Fowler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 34. Nested Function

Compose functions by nesting function calls as arguments of other calls.

image

34.1 How It Works

By representing a DSL clause as a Nested Function, you’re able to reflect the hierarchic nature of the language in a way that’s mirrored in the host language, not just in a formatting convention.

A notable property of Nested Function is the way it affects the evaluation order of its arguments. Function Sequence and Method Chaining both evaluate the functions in a left-to-right sequence. Nested Function evaluates the arguments of a function before the enclosing function itself. I find this most memorable with the “Old MacDonald” ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required