If the problem fits into the limited local resources, if there's no syncing required, no login, no multiplayer, ... Sure, do it. But don't pretend this solves all business cases.
Instead of doing the side effect you return a description and let the framework handle it. E.g. you don't call `transact(db, data)` but return `["transact", db, data]`. Now your function is pure. The framework will expect you to provide the transact handler, e.g. as `register_handler("transact", (db, data) => {..})`.
Personally I'm not a fan of this abstraction (another layer of indirection). I'd rather take a `transact` function as an argument.
I think SBCL starts up fast enough as-is, no? If you want a batteries included version with libraries, just load them and save a new base image with SAVE-LISP-AND-DIE
libmill's goal was to be as close to Go as possible. If you look at it in that light, it's an accomplishment.
Then came libdill, which created the whole "structured concurrency" movement and brought new concepts to light that are now being replicated in python, kotlin, java...
Here's a rudimentary display function that displays a list of moves:
∇display moves
colours←↑(0 255 0)(0 0 0)(0 0 255)(255 0 0) ⍝ green black blue red
'b'⎕WC'Bitmap'('Bits'(0 0⍴0))('CMap'colours) ⍝ create bitmap
'f'⎕WC'Form' 'Snake demo'('Size' 500 500)('Coord' 'pixel')('Picture'b) ⍝ create form with b as the background
s←1 ¯1@(⍉↓10 10⊤2?100)⊢10 10⍴0 ⍝ start position
b.Bits←50/50⌿(¯1 0 1,⌈/,s)⍸s ⍝ display snake
:For move :In moves ⍝ loop over moves
s←move snake s ⍝ update using 'snake' function
b.Bits←50/50⌿(¯1 0 1,⌈/,s)⍸s ⍝ update bitmap
⎕DL÷50 ⍝ delay by 1/50 s
:EndFor
∇
I'd like to syntax highlight code blocks. I tried to add PrismJS to the html file. The CSS survives, but my <script> tag seems to disappear no matter where I put it. I guess this is because Feather Wiki is rewriting itself. How can I add a <script> tag that survives?
The Choo framework is set up to replace the <body> with its render, but any <script> on the page when it's loaded should run—it just won't appear in the inspector after Choo renders.
EDIT: Unless you're talking about it surviving after saving the wiki, in which case it won't remain. I'm actively working on support for extending Feather Wiki that allows whatever custom JavaScript you want, in a very similar way to how the custom CSS is preserved. But it's not ready yet. Keep an eye out for version 1.3.0 in the near future!
At a bare minimum your code might have different behavior. Your `run! deref` will wait for each future one by one. What if the last one threw an exception while the others are running? You'd probably want the other tasks to get canceled immediately. I'm not sure what Executor.close() does exactly, but in theory it could do this for you automatically. Not something I want to write by hand for sure[1].
> In Go for example, I don't remember having to clean up fibers manually.
And that is awful if you think about it a bit. There's no composition happening, your go block just goes off somewhere without you having any control of it. It's like goto, only it forks first and never gives back the process handle[2].
Hum, handling the first to error and interrupt the others is a good use case.
From what I read, Loom structured concurency will not automatically interrupt the other tasks though. And the .close I think will wait for all of them to complete. They said it's because you might not always want other tasks to cancel, so they made it more explicit.
But arguably, maybe if you had a catch in there it would be triggered on the first task to throw. But I can also imagine a similar function to wait for the first future to return or error in Clojure. Though I'm guessing at that point one might say that's just implementing structured concurency?
My question maybe was about the need to close virtual threads. Are they just abusing Closeable so you can use .close as a wait for all to complete even when errors are thrown feature, or do you actually leak resources if you don't clean up Virtual Threads you're done using?