On Saturday, 6 June 2015 at 13:44:51 UTC, Jacob Carlborg wrote:
On 2015-06-06 08:59, Jonathan M Davis wrote:
On Saturday, 6 June 2015 at 06:16:17 UTC, Andrei Alexandrescu
wrote:
Nested functions that allocate their environment dynamically
can be
quite useful. However, oftentimes the need is to convert the
code plus
the data needed into an anonymous struct that copies the
state inside,
similar to C++ lambdas that capture by value.
I wonder how to integrate that within the language nicely.
Some of us were discussing this at dconf. Essentially, we need
a way to
create a functor similar to how C++ lambdas do. The most
straightforward
way would involve string mixins, and you'd do something like
auto f = makeFunctor!"function code here"(arguments);
Which could look like this with AST macros ;)
auto f = makeFunctor(args) {
function code goes here, no strings are needed
}
That may be, but Walter and Andrei have definitively said that
we're never getting AST macros, so there isn't really in point in
worrying about what could be done with them.
- Jonathan M Davis