3 ms·
I am not very familiar with Free Pascal. Does it have coroutines ? Modula2 does but there aren't that many free and maintained implementations around. There is
by srean 6y ago
I am not very familiar with Free Pascal. Does it have coroutines ? Modula2 does but there aren't that many free and maintained implementations around. There is of course GNU's Modula, but it wasn't very easy to install.
- nurettin 6y agofpc has no coroutines. Delphi has them. In fpc, You can declare a procedure or function within another, but that's about it. Authors are skeptical of its utility. https://forum.lazarus.freepascal.org/index.php?topic=45818.45 https://forum.lazarus.freepascal.org/index.php?topic=45818.4...
- FpUser 6y agoYou are confusing coroutines with anonymous functions / lambdas.
- nurettin 6y agoWow, silly me I misread that thanks for the correction sorry gp. Yes, it has coroutines in the sense that you can queue functions to be run as soon as the event queue is drained, so that it looks like your UI is responsive, but they probably won't be able to run concurrently unless said event loop runs on a separate thread which I don't think it does correct me if I'm wrong.
- FpUser 6y agoCoroutines do not really run concurrently unless you yield explicitly or call functions that do async io (those yield automatically). The main reason it is directly available in languages like Go is that they are meant for building servers that do lots of network/file interactions and very little actual calculations. In this pattern coroutine looks rather natural and your code is not riddled with endless explicit yields. As soon as you step out of that pattern coroutines became headache where once must constantly watch and make sure that the interval between yields is not too big and they do not block each other. In my opinion coroutines are an artificial construct that is very specific to the OS (Windows has fibers for example) and one can argue that it belongs to some standard library rather than first order language construct. Well Delphi is guilty in this department as well. It has direct language support for automation services on Windows for example.
- srean 6y ago> In my opinion coroutines are an artificial construct that is very specific to the OS Coroutines are very convenient outside of OS too. Pipeline of operations, alternative to event loops, agents in a game, ETL all seem (to me) a lot more natural with coroutines than say with OOP. In some languages one has to resort to (preemptive) OS threads for these. Those end up being very heavy weight.