I am interested in defining a parallel map operator for my language. It transforms a list into a new list given an expression. It would have a syntax similar to a generator. Unlike generators in C# and Python, it would potentially be evaluated in parallel, if the compiler desires (e.g. there is an idle core, and the list is really big). It would be called witheach
to distinguish it from foreach
which is executed sequentially.
For example consider:
var f = function(int x) : int { return x * 2; }
var my_list = 0..1000000;
var my_mapped_list = witheach (i in mylist) yield f(i);
My question is, is this going to be too unintuitive for programmers who may put side-effects in f
? Of course, I would say not to do this in the documentation, but most programmers don't read language documentation. :-)
I guess the bigger question, is can modern day programmers adapt to implicit parallel list processing semantics in their language, or do they need things to be more explicit?