Comment by packetlost

24 days ago

The use <- syntax is even more crazy when you realize that it's a programmer-friendly way of doing continuation-passing style.

In a language that is otherwise as simple as it could possibly get away with (no `if`!), `use <-` initially feels like magic and somewhat out of place.

But take look at nested callback code, the pyramid of doom, and you see why it's pragmatically necessary. It's a brilliant design that incorporates just enough metaprogramming magic to make it ergonomic. The LSP even lets you convert back and forth between nested callback style and `use`, so you can strip away the magic in one code action if you need to unravel it.

I prefer kotlins trailing lambdas, which do mostly the same. But the way they are written allows code to almost look like JSON/some declarative DSL.

But use is nicer to avoid callback hell and all the indentations/scoping.