Skip to content

Instantly share code, notes, and snippets.

@kikito
Created April 26, 2011 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikito/941962 to your computer and use it in GitHub Desktop.
Save kikito/941962 to your computer and use it in GitHub Desktop.
Lua class implementation syntax example, using a DSL similar to Ruby
-- Option 1 "Conservative"
class("Foo", BaseClass, function(self)
def( "instanceMethod", function(self, param1, param2)
...
end)
self.def( "classMethod", function(self, param1, param2)
...
end)
end)
-- Option 2 "DSL-all-the-way-fun-with-metatables"
class "Foo" (BaseClass, function(self)
def "instanceMethod" (function(self, param1, param2)
...
end)
self.def "classMethod" (function(self, param1, param2)
...
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment