{"id":228001,"date":"2014-06-29T14:58:02","date_gmt":"2014-06-29T10:58:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=228001"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=228001","title":{"rendered":"<span class=\"post_title\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446 \u0432 Lua \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0412 Lua \u041e\u041e\u041f \u043d\u0435\u0442. \u0418 \u043e\u043d\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e: \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c, \u043d\u043e \u043f\u043e\u0441\u0442 \u043d\u0435 \u043f\u0440\u043e \u044d\u0442\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0440\u0430\u0441\u043f\u0438\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043a\u0430 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u043e\u043c python-\u0441\u0442\u0438\u043b\u0435. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u0435\u043d \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0430\u0437\u0438\u0441 \u044f\u0437\u044b\u043a\u0430: \u0442\u0430\u0431\u043b\u0438\u0446\u044b, upvalues.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u043b\u043e\u0431<\/h3>\n<p>  \u041d\u0430\u0447\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:  <\/p>\n<pre><code class=\"lua\">local Obj = {} function Obj.spam()     print 'Hello world' end  --[[ \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0442\u0430\u043a: local Obj = {     spam = function()         print 'Hello world'     end, } ]]  Obj.spam()  -- Hello world <\/code><\/pre>\n<p>  \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043e\u0434\u043d\u0438\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u043e\u0439 Obj.spam \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0430\u043c Obj (\u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0437\u0430 \u0441\u0447\u0435\u0442 upvalue), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 this\/self \u0438 \u0442.\u043f. \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u00ab\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u00bb \u044d\u0442\u043e \u0441\u0430\u043c\u0438:  <\/p>\n<pre><code class=\"lua\">local Obj = {} function Obj.spam(self)     print(self) end  Obj.spam(Obj) <\/code><\/pre>\n<p>  \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e lua:  <\/p>\n<pre><code class=\"lua\">local Obj = {} function Obj.spam(self)     print(self) end  function Obj:spam2()     print(self) end  Obj:spam()  -- \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e Obj['spam'](Obj), \u0442.\u0435. \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438. Obj:spam2() Obj.spam(Obj)  -- table: 0x417c7d58 -- table: 0x417c7d58 -- table: 0x417c7d58 <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430\u0436\u0435 \u0441\u0441\u044b\u043b\u043a\u0430 \u0432\u0440\u043e\u0434\u0435, \u0442.\u043a. \u0432\u0441\u0435 \u0442\u0440\u0438 self \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435.<\/p>\n<p>  <i>\u042f\u0432\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 a:b \u0432\u043c\u0435\u0441\u0442\u043e a.b(a) \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 Obj.foo(cls) \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 a.foo(self).<\/i><\/p>\n<p>  \u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433 \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"lua\">local Obj = {     var = 0, }  function Obj:new(val)     self:set(val or 0)     return self end  function Obj:set(val)     self.var = val end  function Obj:print()     print(self.var) end  local a = Obj:new(42) a:print() local b = Obj:new(100500) b:print() a:print()  -- 42 -- 100500 -- 100500 <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0437\u0430\u043c\u0435\u043d\u0435 a.var \u0432\u043d\u0443\u0442\u0440\u0438 b.set. \u0414\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0432 new \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:  <\/p>\n<pre><code class=\"lua\">local Obj = {     var = 0, }  function Obj:set(val)     self.var = val end  function Obj:print()     print(self.var) end  function Obj:new(val)     -- \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443     local inst = {}     -- \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0441\u0435, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 Obj     for k, v in pairs(self) do         inst[k] = v     end      inst.new = nil -- \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u0435\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0439 \u0438\u0437 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0439. \u043c\u043e\u0436\u043d\u043e \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c :)      inst:set(val or 0)     return inst end  local a = Obj:new(42) a:print() local b = Obj:new(100500) b:print() a:print()  -- 42 -- 100500 -- 42 <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0443\u0436 \u0431\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0432\u043e, \u0434\u0430 \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<h3>\u041c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>  \u0412 Lua \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0438 userdata, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u043f\u0440\u043e \u043d\u0438\u0445 \u0440\u0435\u0447\u044c) \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 <a href=\"http:\/\/lua-users.org\/wiki\/MetatableEvents\">\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445<\/a>. \u0422\u0430\u043a\u0438\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0435 (\u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432), \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a \u0438 \u0442.\u0434. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u0435:  <\/p>\n<pre><code class=\"lua\">local mt = {     __add = function(op1, op2)         local op1 = type(op1) == 'table' and op1.val or op1         local op2 = type(op2) == 'table' and op2.val or op2          return op1 + op2     end,      __tostring = function(self)         return tostring(self.val)     end, }  local T = {     val = 0,      new = function(self)         local inst = {}         for k, v in pairs(self) do             inst[k] = v         end          -- \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u044f\u0432\u043d\u043e         setmetatable(inst, getmetatable(self))          return inst     end, }  setmetatable(T, mt)  local a = T:new() a.val = 2 local b = T:new() b.val = 3  print(a) print(b)  print(a + b) print(a + 10) print(100 + b)  -- 2 -- 3 -- 5 -- 12 -- 103 <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u043b\u044e\u0447 __index, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 lua \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<ul>\n<li>\u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u044e\u0447\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0442\u043e \u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430. \u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0436\u0435 \u043a\u043b\u044e\u0447\u0443 \u0432\u043d\u043e\u0432\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u00ab\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00bb);<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u044e\u0447\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0442\u043e \u043a\u043b\u044e\u0447 \u0438\u0449\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0439. \u0415\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u0442\u043e \u0443 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. <s>\u0421\u0430\u043c\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 We need to go deeper.<\/s><\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430:  <\/p>\n<pre><code class=\"lua\">local T = {}  local T_mt = {     __index = T, -- \u0435\u0441\u043b\u0438 \u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0435\u0442 \u043a\u043b\u044e\u0447\u0430, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 }  function T.create()     -- setmetatable \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430     return setmetatable({}, T_mt) end  function T:set(val)     self.val = val or 0 end  function T:print()     print(self.val) end  local a = T.create() a:set(42) local b = T.create() b:set(100500)  a:print() b:print() a:print()  -- \u043f\u043e\u043b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 a.foo = 7 print(a.foo) print(b.foo)  -- \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 T.bar = 7 print(a.bar) print(b.bar) <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0435 a \u0438 b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 new, set \u0438 print. \u0414\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0431\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 T. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432\u044b\u0437\u043e\u0432 a:print() \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 (\u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0432\u0435\u0442\u0432\u044c \u0438\u0441\u043f\u043e\u043b\u0435\u043d\u0438\u044f):  <\/p>\n<pre><code class=\"lua\">getmetatable(a).__index.print(a) <\/code><\/pre>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 lua \u044d\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>  \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044f \u043c\u0430\u0433\u0438\u044e \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c a.bar \u043d\u0430 rawget(a, &#8216;bar&#8217;) \/ rawset(a, &#8216;bar&#8217;, value).<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439 \u043c\u0435\u043b\u043e\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432:  <\/p>\n<pre><code class=\"lua\">local T = {}  setmetatable(T, {     __call = function(cls)         return cls.create()     end, })  -- \u0412\u0441\u0435! \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e T.create() \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e T(): local a = T() local b = T() <\/code><\/pre>\n<h3>\u0420\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u0438\u0434\u0435\u0438<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0432 \u043e\u0431\u0449\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"lua\">local OOP = {}  function OOP.class(struct)     -- \u043c\u0430\u0433\u0438\u044f     return cls -- \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u043d\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u044e end  -- \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 local A = OOP.class {     val = 0,      set = function(self, val)         self.val = val or 0     end,      print = function(self)         print(self.val)     end, }  -- \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c local a = A:create() a:print() a:set(42) a:print() <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043c\u0435 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f:  <\/p>\n<pre><code class=\"lua\">function OOP.class(struct)     local struct = struct or {}      local cls = {}      local function _create_instance()         local inst = {}          for k, v in pairs(struct) do             inst[k] = v         end          inst.__class = cls          return inst     end      setmetatable(cls, {         __index = {             create = _create_instance, -- \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438         },         __call = function(cls)             return cls:create() -- \u0441\u0430\u0445\u0430\u0440 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430         end,     })      return cls end <\/code><\/pre>\n<p>  \u0412\u0441\u0435\u0433\u043e \u0438 \u0434\u0435\u043b\u043e\u0432-\u0442\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0438 \u0432\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0441\u044f \u0435\u0439 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438:  <\/p>\n<pre><code class=\"lua\">-- ...     local function _create_instance()         local inst = {}         -- ...         inst.__class = cls         -- ...     end -- ...  A.clsMeth = function(cls)     print('Hello') end -- ...  a.__class:clsMeth() -- a.clsMeth() \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e <\/code><\/pre>\n<p>  \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041f\u043e\u043a\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0435:  <\/p>\n<pre><code class=\"lua\">-- \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0434\u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430. \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u043c \u043d\u0435\u0442 function OOP.subclass(parent)     return function(struct)         return OOP.class(struct, parent)     end end  local A = OOP.class {     -- ... }  local B = OOP.subclass(A) { -- B \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c A     welcome = function(self)         print('Welcome!')         self:print() -- \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u043a\u0430\u043a \u0441\u0432\u043e\u0435\u0433\u043e     end, }  local b = B() b:print() b:set(100500) b:welcome() <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u043e\u043a:  <\/p>\n<pre><code class=\"lua\">function OOP.class(struct, parent) -- 1. \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044e     local struct = struct or {}      local cls = {}      local function _create_instance()         local base = parent and parent:create() or nil -- 2. \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0435 \u043f\u0440\u0435\u0434\u043a\u0430          local inst = {}          -- 3. \u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0432\u0441\u0435 \u0435\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f         if base then             for k, v in pairs(base) do                 inst[k] = v             end         end          for k, v in pairs(struct) do             inst[k] = v         end          inst.__class = cls          return inst     end      setmetatable(cls, {         __index = setmetatable( -- 4. \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u0430\u043b\u0438\u0446\u0443             {                 create = _create_instance,             }, {                 -- \u0435\u0441\u043b\u0438 \u0447\u0435\u0433\u043e \u043d\u0435\u0442 \u0443 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u0438\u0449\u0435\u043c \u0443 \u043f\u0440\u0435\u0434\u043a\u0430                 __index = function(_, key)                     if parent then                         return parent[key]                     end                 end,             }         ),         __call = function(cls)             return cls:create()         end,     })      return cls end <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u044f\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043e\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 new \u0438 \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"lua\">-- ...     setmetatable(cls, {         -- ...         __call = function(cls, ...)             local inst = cls:create()              -- \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 - \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e             local new = inst.new             if new then                 new(inst, ...)             end              return inst         end,     }) -- ...  local A = OOP.class {     new = function(self, text)         text = text or ''         print('Hello ' .. text)     end, }  local B = OOP.subclass(A) { }  A('world') B('traveler')  -- Hello world -- Hello traveler <\/code><\/pre>\n<p>  \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 (\u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430) \u043f\u0440\u0435\u0434\u043a\u0430 \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e  <\/p>\n<pre><code class=\"lua\">local B = OOP.subclass(A) {     new = function(self, text)         print('B says ' .. tostring(text))     end, }  B('spam') <\/code><\/pre>\n<p>  \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0432\u044b\u0437\u043e\u0432\u0443 A.new. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 super \ud83d\ude42  <\/p>\n<pre><code class=\"lua\">local B = OOP.subclass(A) {     new = function(self, text)         print('B says ' .. tostring(text))         self:super('from B')     end, } -- ...  local function super_func(self, ...)     local frame = debug.getinfo(2)     local mt = getmetatable(self)     assert(mt and mt.__base, 'There are no super method')      local func = mt.__base[frame.name]     return func and func(self, ...) or nil end  -- ...     local function _create_instance()         -- ...          -- \u0432\u043c\u0435\u0441\u0442\u043e \u044f\u0432\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f inst.super \u0432\u044b\u043d\u043e\u0441\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.         -- \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\/\u043f\u043e\u043b\u0435.         -- \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u0438 \u043e\u0431\u0445\u043e\u0434\u0435 pairs(struct), \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u043d\u043e \u043e\u0442 a.super = x \u044d\u0442\u043e \u043d\u0435 \u0441\u043f\u0430\u0441\u0435\u0442.         local inst = setmetatable({}, {             __base = base,             __index = {                 super = super_func,             },         }) -- ... <\/code><\/pre>\n<p>  super \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0414\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c debug.<br \/>  <i>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c (\u0438\u043b\u0438 lua \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430.<\/i><br \/>  <a href=\"http:\/\/www.lua.ru\/doc\/5.9.html\">debug.getinfo()<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0442\u0435\u043a\u0430: 0 \u2014 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 (super_func), 1 \u2014 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u0433\u0434\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438 super_func,\u2026 \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 super, \u0442.\u0435. \u043f\u043e\u043b\u0435 name \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0442\u0435\u043a\u0430.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \ud83d\ude42<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 private \u043f\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043e\u0431 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u0430\u043a \u0432 python, \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0447\u0435\u0440\u0435\u0437 upvalues:  <\/p>\n<pre><code class=\"lua\">local A = OOP.class((function()      -- \u043d\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u0437 \u043f\u043e\u0442\u043e\u043c\u043a\u0430     local function private(self, txt)         print('Hello from ' .. txt)     end      return {         val = 0,          public = function(self)             private(self, 'public')         end,     } end)()) <\/code><\/pre>\n<p>  \u041d\u0443 \u0442\u0443\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e. \u041c\u0435\u043d\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 Lua. \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0442\u043e, \u0432\u0438\u0434\u0438\u043c\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u0437\u0440\u044f.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0438 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/AterCattus\/estrela\/blob\/dev\/lib\/estrela\/oop\/single.lua\">\u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0443\u0442<\/a>.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/228001\/\"> http:\/\/habrahabr.ru\/post\/228001\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0412 Lua \u041e\u041e\u041f \u043d\u0435\u0442. \u0418 \u043e\u043d\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e: \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c, \u043d\u043e \u043f\u043e\u0441\u0442 \u043d\u0435 \u043f\u0440\u043e \u044d\u0442\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0440\u0430\u0441\u043f\u0438\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043c\u0435\u0442\u0430\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043a\u0430 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u043e\u043c python-\u0441\u0442\u0438\u043b\u0435. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u0435\u043d \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0430\u0437\u0438\u0441 \u044f\u0437\u044b\u043a\u0430: \u0442\u0430\u0431\u043b\u0438\u0446\u044b, upvalues.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-228001","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/228001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=228001"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/228001\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=228001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=228001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=228001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}