{"id":17011572,"url":"https://github.com/mebens/closureclass","last_synced_at":"2025-07-06T01:38:07.947Z","repository":{"id":139500687,"uuid":"1466986","full_name":"mebens/closureclass","owner":"mebens","description":"A Lua object-orientation library based on MiddleClass, except using the closure approach. More information soon.","archived":false,"fork":false,"pushed_at":"2011-03-12T19:41:07.000Z","size":100,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T12:49:22.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.nova-fusion.com","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mebens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-11T06:16:40.000Z","updated_at":"2021-08-03T07:35:09.000Z","dependencies_parsed_at":"2023-03-14T19:15:46.464Z","dependency_job_id":null,"html_url":"https://github.com/mebens/closureclass","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebens%2Fclosureclass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebens%2Fclosureclass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebens%2Fclosureclass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebens%2Fclosureclass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mebens","download_url":"https://codeload.github.com/mebens/closureclass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244960402,"owners_count":20538800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T06:07:28.598Z","updated_at":"2025-03-22T13:22:52.593Z","avatar_url":"https://github.com/mebens.png","language":"Lua","readme":"# Description\n\nClosureClass is an experimental Lua object-orientation library, with the catch that it uses the [closure approach](http://lua-users.org/wiki/ObjectOrientationClosureApproach) instead of the traditional use of table indexing and such. It's based off [MiddleClass](http://github.com/kikito/middleclass) in design.\n\nNote that performance isn't good for this library at present. When compared against MiddleClass, for creating instances of classes, it's about two times as slow, and takes more than two times as much memory. However, it does take about 4/5 the speed of MiddleClass when accessing and calling instance methods.\n\n# Difference in Use\n\nTake this code using MiddleClass for example:\n\n    Foo = class('Foo')\n    \n    function Foo:initialize()\n      self.hello = 3\n      self.boo = 4\n      self:initSomeMore()\n    end\n    \n    function Foo:initSomeMore()\n      -- blah!\n    end\n    \n    function Foo:instanceFunc()\n      -- blah!\n    end\n    \n    f = Foo:new()\n    f:instanceFunc()\n    \n    Bar = class('Bar', Foo)\n    \n    function Bar:initialize()\n      Foo.initialize(self)\n      self.bar = 5\n    end\n    \nWe can do the same thing in ClosureClass using this:\n\n    Foo = class('Foo', function(self)\n      function self.initSomeMore()\n        -- blah!\n      end\n      \n      function self.instanceFunc()\n        -- blah!\n      end\n    \n      self.hello = 3\n      self.boo = 4\n      self.initSomeMore()\n    end)\n    \n    f = Foo.new()\n    f.instanceFunc()\n    \n    Bar = class('Bar', Foo, function(self)\n      -- initialization function implicitly called for now\n      self.bar = 5\n    end)\n    \nMixins are relatively the same in ClosureClass:\n\n    Mixin = {}\n    \n    function Mixin:something()\n      print('blah!')\n    end\n    \n    Foo = class('Foo').include(Mixin)\n    f = Foo.new()\n    f.something() -- \"blah!\"\n    \nNotice how we declare mixin functions with self as a parameter. This is because mixin functions are outside the main closure. However, ClosureClass wraps these function so that using the colon syntax of calling methods isn't needed.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmebens%2Fclosureclass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmebens%2Fclosureclass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmebens%2Fclosureclass/lists"}