You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement parallelism using async keyword on function calls:
voiddefiterate_and_print(numlista)foreachaasiprintiendendasynciterate_and_print([1,2,3,4,5])print"Print me in the mean time"
The output should look like:
1
2
Print me in the mean time
3
4
5
The async should also be assignable so that using the wait keyword the execution can wait until the function called by async finishes:
numdefiterate_print_and_return_last(numlista)foreachaasiprintiendnumr=a[-1]returnrendptrcall=asynciterate_print_and_return_last([1,2,3,4,5])print"Print me in the mean time"wait[numa=call]echo"Last element: "printa
wait keyword should be able to accept a num list:
numdefiterate_print_and_return_last(numlista)foreachaasiprintiendnumr=a[-1]returnrendptrcall1=asynciterate_print_and_return_last([1,2,3,4,5])ptrcall2=asynciterate_print_and_return_last([6,7,8,9,10])print"Print me in the mean time"wait[numa=call1,numb=call2]echo"Last elements: "echoaecho", "printb
such that the output will look like:
1
2
6
3
Print me in the mean time
8
4
9
5
10
Last elements: 5, 10
The text was updated successfully, but these errors were encountered:
Though admittedly I'm curious how you want to implement this under the hood. The only implementation semantically resembling yours is the one in Dao which though uses plain os-level threads. But you seem to indicate that you want to have it single-threaded which would mean either you need to distinguish between return and yield (which I can't find anywhere in your description) or simply insert yield points automatically in compile time (which I also can't find anywhere in your description 😉). Or I'm missing some other option... IDK
@dumblob it's just a syntax proposal at this point. I've no idea how are we going to implement it. Also the current state of master far from making parallelism possible. Right now, I'm focused on making the language JIT compiled. So this RFC is kind of on hold.
Implement parallelism using
async
keyword on function calls:The output should look like:
The
async
should also be assignable so that using thewait
keyword the execution can wait until the function called byasync
finishes:wait
keyword should be able to accept anum list
:such that the output will look like:
The text was updated successfully, but these errors were encountered: