On Monday, 27 February 2017 at 11:53:09 UTC, ag0aep6g wrote: You can generate wrapper functions that have no overloads:
---- static int wrap(alias f)(int arg) { return f(arg); } enum addrOf(alias f) = &f; enum fptrs = staticMap!(addrOf, staticMap!(wrap, funcs)); /* ... r and foreach as before ... */ ----
I'm in awe. <Taking deep bow>
[...] the template stuff just seems to add complexity.
Yes, but the template is one of my constraints (no pun). It needs to happen in there.
This compiles when I apply this to the Pegged source, but something else is wrong. I get a bus error some time out in execution. Maybe when tasks are garbage collected? Or because of missing synchronisation on the array that the tasks write into? This is a complicated situation, because the evaluation of these functions may themselves cause a parallel foreach on a different set of functions (or the same set, for recursive rules). I might not be able to solve this, sadly -- a parser that does parallel matching would have been so cool.
Anyway I am glad to have seen powers of meta programming that I didn't know were possible.
Bastiaan.