From: David Abrahams (dave_at_[hidden])
Date: 2005-11-04 12:14:56
Joel de Guzman <joel_at_[hidden]> writes:
> Comments, feedback very welcome!
> #include <boost/spirit/phoenix/core/value.hpp>
> Whenever we see a constant in a partially applied function, an
> actor<value<T> >
> (where T is the type of the constant) is automatically created by
> default for us.
> For instance:
> add(arg1, 6)
> Passing a second argument, 6, an actor<value<int> > is implicitly
> created behind the scenes. This is also equivalent to:
> add(arg1, val(6))
> val(x) generates an actor<value<T> > where T is the type of x.
I think the use of "us" here is awkward. "You" would be better.
"automatically by default" is confusing language. If you're not
prepared to tell people what happens when the default is not taken,
you probably shouldn't mention that it's a default at all. Also, I
doubt that it's really _wherever_ a constant appears in a partially
foo<2>() + arg1
To represent a value of type T as
an actor, we can use the value template.
is an actor that returns x when invoked. For instance,
is equivalent to
an actor that, when invoked, returns the value 6.
In expressions combining actors with values, the val() function is
invoked implicitly, so
is equivalent to
an actor that adds 6 to its first argument.
> In most cases, there's really no need to explicitly use val. There
> are situations though, as we'll see later on, where this is
..., but as we'll see later on, there are situations where it is
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk