Module class

Minimal class helper for the OOP-style modules (e.g.

socket.inet, socket.unix). Calling the module on a table makes it an instantiable class: it gains a :new constructor that wires __index/__close and sets the class as the metatable of new objects, serving both to build instances and to derive specializations (subclasses that inherit the methods).

Usage:

    local class = require("class")
    
    local Point = class{}
    function Point:sum() return self.x + self.y end
    
    local point <close> = Point:new{x = 1, y = 2}   -- point:sum() == 3
    


generated by LDoc 1.5.0 Last updated 2026-07-04 13:06:33