Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 16:04:00 UTC, Bastiaan Veelo wrote: I get a bus error some time out in execution. It could be that I am running out of stack space. I am on OS X, and non-main threads are given a very limited stack size, they say [1, 2]. This foreach of mine calls into itself,

Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
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) = enum fptrs = staticMap!(addrOf, staticMap!(wrap, funcs)); /* ... r and foreach as before ...

Re: Parallel foreach over AliasSec?

2017-02-27 Thread ag0aep6g via Digitalmars-d-learn
On 02/27/2017 10:52 AM, Bastiaan Veelo wrote: On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote: [...] enum fptr(alias f) = (This is still a bit magical to me: it this a shorthand for a template?) Yes, it's short for this: template fptr(alias f) { enum fptr = } "addrOf" is

Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote: Make a range or an array of function pointers from the AliasSeq of function aliases: import std.meta: staticMap; import std.range: only; enum fptr(alias f) = enum fptrs = staticMap!(fptr, funcs); auto r = only(fptrs); foreach

Re: Parallel foreach over AliasSec?

2017-02-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote: Make a range or an array of function pointers from the AliasSeq of function aliases: import std.meta: staticMap; import std.range: only; enum fptr(alias f) = enum fptrs = staticMap!(fptr, funcs); auto r = only(fptrs); foreach

Re: Parallel foreach over AliasSec?

2017-02-26 Thread ag0aep6g via Digitalmars-d-learn
On 02/27/2017 01:35 AM, Bastiaan Veelo wrote: template eval_all(funcs...) { void eval_all(int val) { import std.parallelism; //foreach (i, f; parallel(funcs))// Tries to evaluate f(void) foreach (i, f; funcs)// How do I parallelise this?