[phoenix] default constructable stateless lambdas

While answering a question about Phoenix on stackoverflow[^1], I discovered that Phoenix lambda types are default-constructable, so long as all the terminals are also default constructable. That's handy when the terminals are stateless. Can it (the default-constructability) be relied on? It doesn't appear to be documented. C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest? Incidentally, I think it's really, really cool that Phoenix allows this kind of extensibility. It's a very nice example of the benefits of the introspection capabilities built into Phoenix. Perhaps this could be worked into the docs somehow? [^1]: http://stackoverflow.com/questions/10144948/static-functions-from-boost-lamb... -- Eric Niebler BoostPro Computing http://www.boostpro.com

On 09/24/2012 09:01 PM, Eric Niebler wrote:
While answering a question about Phoenix on stackoverflow[^1], I discovered that Phoenix lambda types are default-constructable, so long as all the terminals are also default constructable. That's handy when the terminals are stateless. Can it (the default-constructability) be relied on? It doesn't appear to be documented.
That's one of the advantages of taking holding children by value. It also means Phoenix expressions could be serializable.
C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest?
That probably requires that the function object be monomorphic too.

On 9/24/2012 4:38 PM, Mathias Gaunard wrote:
On 09/24/2012 09:01 PM, Eric Niebler wrote:
C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest?
That probably requires that the function object be monomorphic too.
It doesn't. See the implementation here: http://stackoverflow.com/questions/10144948/static-functions-from-boost-lamb... -- Eric Niebler BoostPro Computing http://www.boostpro.com

On 09/25/2012 04:52 AM, Eric Niebler wrote:
On 9/24/2012 4:38 PM, Mathias Gaunard wrote:
On 09/24/2012 09:01 PM, Eric Niebler wrote:
C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest?
That probably requires that the function object be monomorphic too.
It doesn't. See the implementation here:
http://stackoverflow.com/questions/10144948/static-functions-from-boost-lamb...
Oh, you're using a template conversion operator. Very nice indeed.

On 9/25/12 3:01 AM, Eric Niebler wrote:
While answering a question about Phoenix on stackoverflow[^1], I discovered that Phoenix lambda types are default-constructable, so long as all the terminals are also default constructable. That's handy when the terminals are stateless. Can it (the default-constructability) be relied on? It doesn't appear to be documented.
Phoenix-2 required that: http://tinyurl.com/c2y8q2z It seems to have been lost in Phoenix-3: http://tinyurl.com/92fxbze I think it should be reinstated.
C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest?
Incidentally, I think it's really, really cool that Phoenix allows this kind of extensibility. It's a very nice example of the benefits of the introspection capabilities built into Phoenix. Perhaps this could be worked into the docs somehow?
[^1]: http://stackoverflow.com/questions/10144948/static-functions-from-boost-lamb...
Most definitely! Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

On Tuesday, September 25, 2012 07:56:49 Joel de Guzman wrote:
On 9/25/12 3:01 AM, Eric Niebler wrote:
While answering a question about Phoenix on stackoverflow[^1], I discovered that Phoenix lambda types are default-constructable, so long as all the terminals are also default constructable. That's handy when the terminals are stateless. Can it (the default-constructability) be relied on? It doesn't appear to be documented.
Phoenix-2 required that: http://tinyurl.com/c2y8q2z
It seems to have been lost in Phoenix-3: http://tinyurl.com/92fxbze
I think it should be reinstated. *nod*
C++11 lambdas have the nice property that stateless ones are implicitly convertible to raw function pointers. This can be implemented for Phoenix if we can rely on the default-constructability of Phoenix lambda types. In my stackoverflow answer I show how. It'd be pretty cool if this were a standard part of all Phoenix lambdas. Is there interest?
Incidentally, I think it's really, really cool that Phoenix allows this kind of extensibility. It's a very nice example of the benefits of the introspection capabilities built into Phoenix. Perhaps this could be worked into the docs somehow?
[^1]: http://stackoverflow.com/questions/10144948/static-functions-from-boost-la mbda-or-boost-phoenix/12326204#12326204 Most definitely!
Woah. this is insanely cool! Let's have it I say! (I'd say feel free to commit the changes and drop us a note when you are done)
Regards,

On 9/24/2012 10:50 PM, Thomas Heller wrote:
On Tuesday, September 25, 2012 07:56:49 Joel de Guzman wrote:
On 9/25/12 3:01 AM, Eric Niebler wrote:
Incidentally, I think it's really, really cool that Phoenix allows this kind of extensibility. It's a very nice example of the benefits of the introspection capabilities built into Phoenix. Perhaps this could be worked into the docs somehow?
[^1]: http://stackoverflow.com/questions/10144948/static-functions-from-boost-la mbda-or-boost-phoenix/12326204#12326204
Most definitely!
Woah. this is insanely cool! Let's have it I say! (I'd say feel free to commit the changes and drop us a note when you are done)
My free time is pretty limited. I'm sure you can relate. I was hoping that one of the Phoenix maintainers (nudge!) would take an interest and integrate the idea. :-) -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (4)
-
Eric Niebler
-
Joel de Guzman
-
Mathias Gaunard
-
Thomas Heller