Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Is Lua object oriented? — Gideros Forum

Is Lua object oriented?

mobileguymobileguy Member
edited September 2012 in General questions
According to lua.org, Lua has been OO since 1995:
"Lua 2.1 was released on 07 Feb 1995. Its main new features were extensible semantics via fallbacks and support for object-oriented programming."

But according to the Gideros documentation:
"Lua itself does not support classes, but Gideros does. This document explains how to emulate OO programming and classes in Lua."

Comments

  • MellsMells Guru
    edited September 2012

    About Lua

    # Lua Classes With Metatable
    Lua has matured from an application extension language into a wonderfully flexible scripting language. Lua 5.0 is not an object oriented language like Java or Ruby. Instead, Lua gives you the ability to implement classes however you wish. This is both a bonus and a bane. Power users love the freedom, but newbies are sometimes baffled.
    [ Source ]

    About Gideros

    @atilim said :
    in fact, gideros.class (Note : now deprecated, use Core.class instead) is a simple Lua OO mechanism. Except inheritance, Its implementation is very similar to the code below. You can directly use this instead of inheriting from EventDispatcher:
    LinkedList = {}
    LinkedList.__index = LinkedList
     
    function LinkedList.new(...)
    	local self = setmetatable({}, LinkedList)
    	if self.init ~= nil and type(self.init) == "function" then
    		self:init(...)
    	end	
    	return self
    end
     
    -- your actual LinkedList implementation starts from here
     
    function LinkedList:init()
     
    end
    [ Source ]

    Likes: Teranth

    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.