|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-11-04 12:14:56
Joel de Guzman <joel_at_[hidden]> writes:
> Comments, feedback very welcome!
> Values
>
> #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
applied function:
foo<2>() + arg1
I suggest:
To represent a value of type T as
an actor, we can use the value template.
actor<value<T> >(x)
is an actor that returns x when invoked. For instance,
actor<value<int> >(6)
is equivalent to
val(6)
an actor that, when invoked, returns the value 6.
In expressions combining actors with values, the val() function is
invoked implicitly, so
add(arg1, 6)
is equivalent to
add(arg1, val(6))
an actor that adds 6 to its first argument.
> In most cases, there's really no need to explicitly use val. There
^^^^^^
strike
> are situations though, as we'll see later on, where this is
> unavoidable.
..., but as we'll see later on, there are situations where it is
unavoidable.
-- 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