Created
April 26, 2011 08:01
-
-
Save kikito/941962 to your computer and use it in GitHub Desktop.
Lua class implementation syntax example, using a DSL similar to Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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