lights FAQ Forum

Native OS APIs


single inheritance object model

This module defines an user API and an implementation protocol for implementing a single-inheritance object model.

The API is comprised of 2 functions:

  • subclass(derived[, super]) -> derived
  • isinstance(object, class) -> true|false

subclass() calls super:__subclass(derived) to perform the actual subclassing and returns derived. This means that each class is free to define how subclassing should be performed (copy all members to the derived class aka static inheritance, assign an __index metamethod aka dynamic inheritance, etc.). If the super class doesn't define a __subclass method, nothing gets inherited and derived is returned untouched.

isinstance() calls object:__super() recursively until it matches the wanted class. Classes must implement __super() for this to work.

Note that there's no API or implementation protocol for instantiation. The root class should define these.

The Object class implements this model using dynamic inheritance.

Last updated: 2 years ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r3-8-g8ecae71
Last commit:
License: PD
Requires: cairo  glue  luajit  opengl  sg  eq  path2d  pp 
Required by: cairo  cplayer  nw  opengl  sg