logoalt Hacker News

noelwelshtoday at 9:07 AM1 replyview on HN

What Zig is doing is called "capability passing". I don't know if the Zig team is aware of this field of work, or have independently arrived upon it, but that's what is achieved by passing IO, memory allocators, and other stuff around.

The core idea is that you create a "capability" for any action you want to track, such as using IO, allocating memory, or in your example making cross core or cross server calls. Now to perform these actions code has to have access to the capability. It's a very simple, but powerful, model.

The Effekt language formalizes this, and adds safety properties: https://effekt-lang.org/ Scala 3 also has this.

The papers are pretty readable, if you ignore the middle bits which go into the formal models.


Replies

epolanskitoday at 10:06 AM

That looks like a convoluted way to describe dependency injection to me, what am I missing.

show 1 reply