July 2015
Intermediate to advanced
558 pages
13h 31m
English
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.
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. ...
Read now
Unlock full access