Skip to content

Instantly share code, notes, and snippets.

@Deco
Deco / geometry.lua
Created Feb 2, 2012 — forked from Deco/geometry.lua
Luvit module example (using local _M table and self-referencing)
View geometry.lua
local OO = require"oo"
local _M = {}
do _M.Shape = OO.class({
})
function _M.Shape:__init()
error("attempt to instantiate abstract shape")
end
@Deco
Deco / geometry.lua
Created Feb 2, 2012 — forked from Deco/geometry.lua
Luvit module example (using local _M table) (my personal choice)
View geometry.lua
local OO = require"oo"
local _M = {}
do _M.Shape = OO.class({
})
function _M.Shape:__init()
error("attempt to instantiate abstract shape")
end
@Deco
Deco / geometry.lua
Created Feb 2, 2012 — forked from Deco/geometry.lua
Luvit module example (using exported locals)
View geometry.lua
local OO = require"oo"
local Shape, Rectangle, Circle
do Shape = OO.class({
})
function Shape:__init()
error("attempt to instantiate abstract shape")
end
@Deco
Deco / geometry.lua
Created Feb 2, 2012 — forked from Deco/geometry.lua
Luvit module example (using setfenv to emulate module function)
View geometry.lua
local OO = require"oo"
local setmetatable = setmetatable
local error, assert = error, assert
local type = type
local newproxy = newproxy
local math = require"math"
local tonumber = tonumber
local getfenv=getfenv setfenv(1, {})
@Deco
Deco / geometry.lua
Created Feb 2, 2012 — forked from Deco/geometry.lua
Luvit module example (using module)
View geometry.lua
local OO = require"oo"
local setmetatable = setmetatable
local error, assert = error, assert
local type = type
local newproxy = newproxy
local math = require"math"
local tonumber = tonumber
module("geometry")