4. Classes and interfaces

Classes hold fields and methods. There are NO function values and NO closures — a deliberate doctrine: behavior travels as a class satisfying an interface, and satisfaction is structural (same method name and shape, Go-style, no implements). This is how the web framework takes handlers.

interface Handler {
  fn handle(req: Req) -> Resp
}

class Hello {
  greeting: Text
  fn handle(req: Req) -> Resp {
    return ok_text("${self.greeting}, ${req.path}");
  }
}

-- any class with a matching handle() satisfies Handler
app.get("/hello", Hello { greeting: "hi" });

Chapters