Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8564: Variable hiding errors within nested let blocks in Phoenix
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-08 19:59:32
#8564: Variable hiding errors within nested let blocks in Phoenix
-------------------------------+---------------------
Reporter: miremare@⦠| Owner: theller
Type: Bugs | Status: new
Milestone: To Be Determined | Component: phoenix
Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------
Comment (by John Fletcher <J.P.Fletcher@â¦>):
This is indeed a bug and the examples given do not work. The solution is
to use either an argument e.g _1 or a local variable e.g. _a to assign
value to the local variable in the inner let.
These examples both work with the definitions
{{{
namespace phoenix = boost::phoenix;
using namespace phoenix::local_names;
using boost::phoenix::arg_names::_1;
using boost::phoenix::arg_names::_2;
using boost::phoenix::arg_names::_3;
using std::cout;
}}}
{{{
phoenix::let(_x = _1, _y = _2)
[
let(_x = _3) // hides the outer _x
[
cout << _x << _y // prints "Hello, World"
]
](1," World","Hello,");
cout << std::endl;
}}}
{{{
phoenix::let(_x = _1, _y = _2, _z = _3)
[
let(_x = _z) // hides the outer _x
[
cout << _x << _y // prints "Hello, World"
]
](1," World","Hello,");
cout << std::endl;
}}}
I will investigate further and also change the documentation. John
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8564#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC