30 lines library for object orientation in Lua
class:create
, which allocates a new instance without invoking the class initializer30log-commons.lua
class:cast()
, changes the class of an instanceclass:subclasses()
returns the list of all classes which extend from class
class:instances()
, returns the list of all instances of class
class:classOf()
, checks if class
is a superclass of argclass:subclassOf()
, checks if class
is a subclass of arginstance:instanceOf()
, checks if instance
is an instance of argclass:without()
to remove a mixin from a classclass:with()
, includes a mixin to a classclass.isClass
, now only checks if arg is a classclass.isInstance
, now only checks if arg is an instanceclass:include()
class
is considered to be the instance of any superclass of class
require "30log"
now returns a callable tableclass.isClass
class.isInstance
subclass.super
returns the superclass
of subclass
instance.class
returns the class
of instance
class
prototype to class(name, params)
class:__init()
to class:init()
class.__name
to class.name
class:extends()
to class:extend
class:is()
to class:extends
class:has()
to class:includes
class:extend
prototype to class:extend(name, params)
tostring(class)
and tostring(instance)
output.class.is
and instance.is
to inspect inheritance relationship between two objects.include
, not with
new
__tostring
output (class (?)
instead of class (Unnamed)
)30logclean
(Thanks zorfmorf)__init
can either be a table or a function