News for hackers. Stuff that matters.
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`)