Domain Specific Embedded Languages

In the last third of this chapter, we look at the applications of higher order and compile-time programming mainly in the area Domain Specific Embedded Languages.

Lazy evaluation

In C++, when we see the following code:

z = x + y();

We know that the value of z is immediately computed when the control reaches past the statement z = x + y(). In fact, the act of computing the sum involves evaluating the expressions x and y() themselves. Here, y is presumably a function or a functor instance, so the call to y() will in turn trigger more evaluations. Irrespective of whether z is ever used for anything later, its value would still be computed. This is the model of eager evaluation that a lot of programming languages follow. ...

Get Learning Boost C++ Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.