3 ms·
An aspect of Modula-2 that I find so interesting is its support for coroutines. Is there any modern and permissibly licensed (GPL, BSD, MIT, Mozilla ...) implem
by srean 6y ago
An aspect of Modula-2 that I find so interesting is its support for coroutines. Is there any modern and permissibly licensed (GPL, BSD, MIT, Mozilla ...) implementation that has an efficient implementation (low context switch time). I am not looking for anything that rides on pthreads api or library, or anything that maps to OS threads.
- naltun 6y agoFWIW, Mozilla Public License is a weak copy left license that has many benefits of permissive licenses. But it is copyleft.
- pjmlp 6y agoIf you mean bare metal Modula-2, I am afraid it is all gone by now, given its surviving compilers. However what about Ada tasks?
- srean 6y agoThat's rather sad to hear. I presume some of it lives in Go and Nim. Don't know Ada, its tasks, even less.
- pjmlp 6y agoYou can do a round over here, https://freepages.modula2.org/compi.html https://freepages.modula2.org/compi.html As for Ada tasks, https://learn.adacore.com/courses/intro-to-ada/chapters/tasking.html https://learn.adacore.com/courses/intro-to-ada/chapters/task...
- MaxBarraclough 6y agoAs someone who doesn't know Ada very well: Ada 'tasks' look like ordinary threads but with integrated message pumps. Is that about right?
- Jtsummers 6y agoThere's a bit more to it. I think one of the more novel (hah! 40 years old now) aspects is that tasks can be declared on the stack which allows for structured concurrency to be done in Ada without needing a separate library. Something like (outline): package body SomethingSomethingDarkside is procedure Foo(N : Integer) is task A ... task B ... task C ... task type D ... Bunch_Of_Ds : array (1..N) of D; begin DoStuff; end Foo; -- doesn't actually terminate until all the above terminate begin Foo; Put_Line("Won't be printed until after all of Foo's tasks finish."); end SomethingSomethingDarkside; -- Neatly fits the intention of Structured Concurrency. Tasks can also be allocated on the heap which allows you to have something more like what conventional threads or Go routines or Erlang processes do. And protected objects come with built in mutexes and blocking conditions on entries to prevent race conditions or control system invariants. https://en.wikipedia.org/wiki/Structured_concurrency https://en.wikipedia.org/wiki/Structured_concurrency