Monday, May 14, 2012

OOP in Lua

가장 알기 쉬운 설명 링크 :
[1] Object Orientation Closure Approach
[2] Lua OOP (Litt's Lua Laboratory)
[3] Programming in Lua - Chapter 16. Object-Oriented Programming
[3]은 [1], [2]를 다 이해한 후에 보는 것이 알기 쉬움

보충 :
[2] 에서 좀 잘못된 부분이 있는데
 Point.new = function(x, y)       
      -- #PRIVATE VARIABLES  
      local self = {}    -- Object to return  
      x = x or 0      -- Default if nil  
      y = y or 0      -- Default if nil  
와 같은 코드가 있는데 이렇게 하면 x와 y는 global variable이 되어 버린다.
local x, local y 로 해주어야 함.

미러 :
Lua로 Object Oriented Programming 하기 - class 정의하기/Lua OOP.html
Lua로 Object Oriented Programming 하기 - class 정의하기/lua-users wiki - Object Orientation Closure Approach.html

참고자료 모음 :
Object Orientation Closure Approach
Object Orientation Tutorial - Representation of classes in Lua
Object Oriented Programming in Lua
Inheritance Tutorial
Metamethods Tutorial
Inspired Lua - Object Classes

인용 : Lua wasn't built with OOP in mind, it was built with atomic computer programming features such as closures, iterators, tables, metatables, tail recursion.
출처 : Discussion: Many Ways to Do OOP
키워드 : Object Oriented, class definition

No comments:

Post a Comment