Boost C++ Libraries: Ticket #4425: qi::action ignores phoenix actor return value https://svn.boost.org/trac10/ticket/4425 <p> Hello, </p> <p> this is not really a feature request but rather a design issue: It seems to me there is a discrepancy between the behavior of phoenix actors in comparison to functors called from qi actions. In a functor, you can fail an otherwise successful parser by changing the "pass" argument. Intuitively, I would have thought that a phoenix actor such as eps [phoenix::val(true) == phoenix::val(false)] should also fail the parser. However, action_dispatch ignores the return value from the actor and returns the pass argument, which the phoenix actor does not modify. I'm not that well-versed in the insides of phoenix, but I can imagine that the actors know nothing about the pass argument. Should it not rather be action_dispatch, which in that case should perhaps AND the actor return value with the pass argument, so as to catch such cases? </p> <p> Just a thought from an otherwise contended spirit user:-) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4425 Trac 1.4.3 anonymous Wed, 14 Jul 2010 06:09:57 GMT attachment set https://svn.boost.org/trac10/ticket/4425 https://svn.boost.org/trac10/ticket/4425 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">action_dispatch.hpp</span> </li> </ul> Ticket anonymous Wed, 14 Jul 2010 06:10:11 GMT <link>https://svn.boost.org/trac10/ticket/4425#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4425#comment:1</guid> <description> <p> Hello again, </p> <p> I've added a step in action_dispatch that checks the return type of phoenix actors: If it is a boolean, the return value is &amp;&amp;ed with the pass argument value. Here is the function: </p> <p> template &lt;typename Eval, typename Attribute, typename Context&gt; bool operator()( </p> <blockquote> <p> phoenix::actor&lt;Eval&gt; const&amp; f, Attribute&amp; attr, Context&amp; context) </p> </blockquote> <p> { </p> <blockquote> <p> bool pass = true; typename pass_attribute&lt;Component, Attribute&gt;::type attr_wrap(attr); </p> </blockquote> <blockquote> <p> typedef typename remove_reference&lt; </p> <blockquote> <p> typename Eval::template result&lt; </p> <blockquote> <p> phoenix::basic_environment&lt; </p> <blockquote> <p> typename remove_reference&lt;Attribute&gt;::type, typename remove_reference&lt;Context&gt;::type, typename remove_reference&lt;bool&gt;::type&gt; &gt;::type &gt;::type </p> </blockquote> </blockquote> </blockquote> <p> return_type; </p> </blockquote> <blockquote> <p> return_type* ret = 0; </p> </blockquote> <blockquote> <p> return call(f, attr_wrap, context, pass, ret); </p> </blockquote> <p> } </p> <p> template&lt;typename Eval, typename Attribute, typename Context, typename Return&gt; inline bool call( </p> <blockquote> <p> phoenix::actor&lt;Eval&gt; const&amp; f, Attribute&amp; attr, Context&amp; context, bool&amp; pass, Return) </p> </blockquote> <p> const { </p> <blockquote> <p> f(attr, context, pass); return pass; </p> </blockquote> <p> } </p> <p> template&lt;typename Eval, typename Attribute, typename Context&gt; inline bool call( </p> <blockquote> <p> phoenix::actor&lt;Eval&gt; const&amp; f, Attribute&amp; attr, Context&amp; context, bool&amp; pass, bool*) </p> </blockquote> <p> const { </p> <blockquote> <p> bool ret = f(attr, context, pass); return pass = pass &amp;&amp; ret; </p> </blockquote> <p> } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Wed, 14 Jul 2010 09:25:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4425#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4425#comment:2</guid> <description> <p> This is not necessary. If you want an actor to be able to fail a parse, just give it the pass argument by using the placeholder _pass. See <a class="ext-link" href="http://tinyurl.com/3xrfcsd"><span class="icon">​</span>http://tinyurl.com/3xrfcsd</a>. Example: p[_pass = false] will always fail parsing. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Sun, 17 Oct 2010 21:33:21 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4425#comment:3 https://svn.boost.org/trac10/ticket/4425#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket