Boost C++ Libraries: Ticket #5857: proto::function undocumented for use in grammars https://svn.boost.org/trac10/ticket/5857 <p> There's no documentation on what template argumentes proto::function takes when defining grammars. </p> <p> Also it appears that proto::function enables the function call operator for protoized types, as well as being used by functions that need to return lazy expressions. This dual use and how to restrict or prevent function call operator overloading should also be documented. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5857 Trac 1.4.3 Joel Falcou Wed, 02 Nov 2011 18:45:40 GMT <link>https://svn.boost.org/trac10/ticket/5857#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5857#comment:1</guid> <description> <p> proto::function is mainly to activate operator()(...) on proto types. Th euse of this tag as a way to define new function int he doc is just an exampel tied to the default_context. A better (as in more scalable) way to do so (lazy function) is to use make_expr as shown later. </p> <p> I'll amend the documentation for the operator()() use case. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 19 Mar 2012 23:42:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5857#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5857#comment:2</guid> <description> <p> John, there is really nothing special to say about <code>proto::function</code> distinct from all the other operator metafunctions in Proto. The multiple uses of these metafunction is discussed <a class="ext-link" href="http://tinyurl.com/7fgy69s"><span class="icon">​</span>here</a>. Is that insufficient? </p> <p> Also, <code>proto::function</code> doesn't "enable the function call operator for protoized types," which makes me think you were trying to say something else(?). Functions that need to return lazy expressions /could/ use <code>proto::function</code> (it is a metafuntion that generates expressions, as described in the above link), but the better tool for that job is <code>proto::make_expr</code>. </p> <p> I feel like you went looking for something in the docs and didn't find it, but I'm not entirely sure what. Now that you know a little more, and you know where in the docs it's described, do you have any suggestions for making the docs more useful? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel Falcou</dc:creator> <pubDate>Tue, 20 Mar 2012 07:31:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5857#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5857#comment:3</guid> <description> <p> Eric i wonder if the example of making a new lazy function using proto::function is not detrimental and should be replaced/removed so the better make_expr solution is more proeminent. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 20 Mar 2012 09:07:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5857#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5857#comment:4</guid> <description> <p> Eric, Joe, </p> <p> My apologies, but this was all a while ago and I haven't used proto since the original discussion on the mailing list. I did look at the link you gave, but was short on time and just got more confused - I see no mention of lazy functions or proto::function there? So &lt;shrug&gt; I guess. I'm sorry I can't be more helpful, but there's something that just isn't clicking for me I guess :-( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 21 Mar 2012 04:35:12 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5857#comment:5 https://svn.boost.org/trac10/ticket/5857#comment:5 <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">fixed</span> </li> </ul> <p> John, the link I gave doesn't specifically talk about <code>proto::function</code>, but it makes a general point about all of Proto's operator metafunctions -- of which there are a great many, including <code>proto::function</code> -- namely, that they can be used in many different capacities. They can compute new expression type, match those type, and transform those types. This seems to be one of those things that all new users of Proto struggle with. It's worth considering whether it indicates a flaw in Proto's design, a flaw in Proto's docs, or if it's Just One Of Those Things, like Haskell's monads, that are powerful but inherently hard to grok. </p> <p> Joel, I had another look at the docs about creating lazy functions, and you're right. I overemphasize <code>proto::function</code>'s role by a lot. I took another crack at it. Have a look <a class="ext-link" href="http://boost-sandbox.sourceforge.net/libs/proto/doc/html/boost_proto/users_guide/front_end/making_lazy_functions.html"><span class="icon">​</span>here</a>. </p> <p> Closing this as fixed, but will continue to think about the overloaded (ab)use of Proto's operator metafunctions for Proto-11. </p> Ticket