classic
classic copied to clipboard
Tiny class module for Lua
```lua function Object:as(T) if self.is(T) then return self end return T end ```
There seems to be a problem with the design of the `is` method. You can't do things like `nil:is(SomeType)` This makes it pretty much useless for type checking as you...
Consider hiding the meta methods. Maybe something like this.. ``` local Object = {} local Meta = { __call = function(self, ...) local obj = setmetatable({}, self) obj:new(...) return obj...
For clarification: If you have a class Point (like the example in the docs), and then want to create a new Point which is correctly done so: `local p =...
```lua -- https://github.com/kikito/middleclass local middleclass = require "middleclass" local CreatureMC = middleclass("CreatureMC") function CreatureMC:__call() print("CreatureMC was called!") end local AnimalMC = CreatureMC:subclass("AnimalMC") local CatMC = AnimalMC:subclass("CatMC") local tomMC = CatMC()...
Here is the difference between **classic** and [middleclass](https://github.com/kikito/middleclass): ```lua local MiddleClass = require "middleclass" local M = MiddleClass("M") function M:initialize() self.pos = {2, 4} self.size = {6, 8} end function...
Hi, I think that mixins are also useful for acting as a sub-class that can be shared between multiple classes instead of making another base class. With that level of...