Developer Tools
vinterface
Declares an interface and checks at run time that a value meets it.
Released v1.0.0 · 2026-09-28use "stdlib/interface.ven"
Explicit interface declarations with a real runtime check that a shape actually satisfies one, distinct from an ordinary behavior block, which attaches methods without declaring or checking a contract. A shape that claims to satisfy an interface is checked against it, and the check fails loudly rather than silently if a method is missing.
surface = new_interface("Runnable", ["run"])
print surface.describe()
Reference (6 functions)
API reference
new_interface(name, methods)
Declares a new interface: a name plus the method names a conforming shape must define.
print(new_interface("Runnable", ["run"]).describe())
:: interface Runnable(run)missing_methods(shape_name, iface)
Lists ifaces required method names that shape_name does not define or inherit.
shape Idle
name: Text
print(missing_methods("Idle", new_interface("Runnable", ["run"])))
:: ["run"]shape_conforms_to(shape_name, iface)
Truth-valued conformance check by declared shape NAME.
shape Runner
name: Text
behavior Runner
make run(self)
give "running " + self.name
print(shape_conforms_to("Runner", new_interface("Runnable", ["run"])))
:: yesconforms_to(value, iface)
Truth-valued conformance check for a concrete VALUE.
print(conforms_to(42, new_interface("Runnable", ["run"])))
:: noimplements(value, iface)
Asserting form of conforms_to: raises a named-missing-method diagnostic when value does not conform.
shape Runner
name: Text
behavior Runner
make run(self)
give "running " + self.name
worker = implements(Runner("track"), new_interface("Runnable", ["run"]))
print(worker.name)
:: trackimplements_all(value, interfaces)
Checks value against every interface in interfaces, raising on the first one it fails.
shape Runner
name: Text
behavior Runner
make run(self)
give "running " + self.name
runnable = new_interface("Runnable", ["run"])
worker = implements_all(Runner("track"), [runnable])
print(worker.name)
:: track