Values |
Whenever we see a constant in a curryable-function such as the plus above, an actor<value<T> > (where T is the type of the constant) is, by default, automatically created for us. For instance, the example plus above is actually equivalent to:
plus(arg1, actor<value<int> >(value<int>(6)))
A nifty shortcut is the val(v) utility function. The expression above is also equivalent to:
plus(arg1, val(6))
actor<value<int> >(value<int>(6)) is implicitly created behind the scenes, so there's really no need to explicitly type everything but:
plus(arg1, 6)
There are situations though, as we'll see later on, where we might want to explicily write val(x).
Like arguments, values are also actors. As such, values can be evaluated through the actor's operator(). Such invocation gives the value's identity. Example:
cout << val(3)() << val("Hello World")();
prints out "3 Hello World".
Copyright © 2001-2002 Joel de Guzman
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)