News for hackers. Stuff that matters.
Re:Hurl, the Exceptional Language by kgeist on Sunday May 26, 2024 @04:59AM (#40480676)
'Toss' sounds like an interesting language construct: it walks the stack to find an exception handler and then walks back to where it was to resume execution as if nothing happened. It looks like you can inject additional behavior at runtime using this construct. Usually in object-oriented code you do dependency injection using services's constructors, but 'toss' allows to do it using "toss handlers"?
Re:Hurl, the Exceptional Language by bradrn on Sunday May 26, 2024 @06:18AM (#40481024)
This is quite similar to the Common Lisp conditions system… which I actually don’t know much about, but I do know that it lets you inject behaviour at runtime like this does.
Re:Hurl, the Exceptional Language by masklinn on Sunday May 26, 2024 @06:56AM (#40481182)
It's a very restricted form of conditions, since it only allows resuming.

A conditions system would subsume both `toss` and `hurl` (because you can have an unwinding restart), as well as provide more flexibility: the condition can provide multiple user-defined restarts and the handler can pick between them (statically or dynamically), as well as feed content back into the signalling function.

For instance a classic CL restart is `use-value` which is the conventional name of restarts feeding a default value in case of missing or invalid item.

So let's say that you have a hashmap type, on lookup failure it could trigger a condition with a `use-value` handler to feed it a default value (possibly dynamically constructed), or abort/unwind, it could also have a restart to insert-and-return the value (so would behave as a `defaultdict`/`putIfAbsent`)

Re:Hurl, the Exceptional Language by mjbrusso on Sunday May 26, 2024 @08:03AM (#40481516)
This is similar `Resume Next` in VB
Re:Hurl, the Exceptional Language by tylerhou on Sunday May 26, 2024 @11:22AM (#40482843)
Check out Koka, a “legit” language with an algebraic effect system.

https://koka-lang.github.io/koka/doc/book.html#why-handlers