These are chat archives for liam4/tlnccuwagnf

12th
Jun 2016
Florrie
@towerofnix
Jun 12 2016 03:25

Just made sleep asynchronous, old sync version sleep-sync! Also, a new launch function!

liam4/tlnccuwagnf@604065e
yield => { sleep(0); };
# Again, a macro would be good here - think replacing yield w/ sleep(0); #

print('DEMO 1 (ASYNC) -------');
print('A');
launch({
  yield();
  print('Hello!')
});
sleep(0.5);
print('B');

sleep(2);
print('DEMO 2 (SYNC) --------');
print('A');
launch({
  yield();
  print('Hello!');
});
sleep-sync(0.5);
print('B');
Florrie
@towerofnix
Jun 12 2016 03:32

Output of program:

DEMO 1 (ASYNC) -------
A
Hello!
B
DEMO 2 (SYNC) --------
A
B
Hello!

(with delays of course)

Arthur
@kvackkvack
Jun 12 2016 08:14
This is actually becoming really cool now, but now I'll have to catch up with all the features and the codebase to feel useful! :P
alex
@heyitsmeuralex
Jun 12 2016 09:45
ooo
async?
MrSherlockHolmes
@MrSherlockHolmes
Jun 12 2016 13:19
nice
wait... isn't the first sync, and the second async? [probably wrong ;D]
Florrie
@towerofnix
Jun 12 2016 16:48

@MrSherlockHolmes sync(hronous) means everything is happening together, in a specific order. Asynchronous means we're just doing everything together.

tlnccuwagnf makes it all simpler when you're actually coding by automatically awaiting for a function to be called.

sleep is different from sleep-sync; one is callback based and the other is blocking-based (it blocks ALL of tulun from doing ANYTHING while it runs).

You don't need to call them differently (besides choosing the right function name of course!); it's just that sleep will finish after launch-yield-print, whereas sleep-sync will finish before launch-yield-print.

In the second demo yield is unnecessary!