sorry, last email was sent to early, my thunderbird is out of control...
So,using an annotation one could write
%async map:for-each(map { 1: 2, 3: 4 }, function($a, $b) { $a + $b })
Seeing Christians mail in the meantime I guess my idea of an annotation is basically the same idea as the pragma. What could be the benefit of a pragma here as can we simply not use an annotation here for some reason I don't see at the moment, Christian?
But I do think the approach would (regardless whether it uses a pragma or an annotation) be viable as well.
Cheers Dirk
On 03/02/2016 05:44 PM, Christian Grün wrote:
Hi Klāvs,
Your feedback is welcome!
for async $i in 1 to 10 return fetch:text("http://example.com/magic-story/for-number/" || $i)
Problem here is that you need to introduce a new keyword to the language. I am just trying to figure out if there could be a solution like this.
That’s true (and the keyword wouldn’t change the result at all). One alternative could be to use a pragma. The following query is valid XQuery 1.0:
declare namespace basex = 'http://basex.org'; for $i in (#basex:async #) { 1 to 10 } return $i * 2
for $i in 1 to 10 return fetch:text-with-implicit-parallel-execution-characteristics("http://example.com/magic-story/for-number/" || $i)
The pragma could also be attached to the return expression, but in many cases (in particular after function inlining), FLWOR expressions can get pretty complex, and it would be a non-trivial task to choose the best for clause for parallelization.
Christian