Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Signal Rebirthed - Page 2
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Signal Rebirthed

  1. #11
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by jeremic View Post
    I think you will have trouble implementing object orientation, as the language needs to be built ground up with that mind.
    An option would be to follow the same trick used by __thiscall calling convention. An approach like this is used in Lua implementation of OO.

  2. #12
    I haven't gotten too far, since I've been busy the last few weeks. Everything I have is currently on the google code repo. I have some ideas for implementing OOP, but it is a bit tricky.

  3. #13
    Senior Member
    Join Date
    Mar 2007
    Posts
    766
    Quote Originally Posted by Blequi View Post
    An option would be to follow the same trick used by __thiscall calling convention. An approach like this is used in Lua implementation of OO.
    I'm not too familiar with LUA, but as far as I recall OO was an afterthought in LUA as the language itself predates the "OOP boom". To me, OO in LUA seems like a big hack using tables. Is this correct?

  4. #14
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    what I meant is that __thiscall basically inserts the "this" pointer as
    the first argument in each instance method call from the class instance (pseudo code):

    Code:
    class SomeClass
    {
        void SomeFunction(T1 param1, T2 param2, ...);
    }
    
    SomeClass c = new SomeClass();
    c.SomeFunction(param1, param2, ...);
    is basically

    Code:
    SomeFunction(SomeClass& this, T1 param1, T2 param2, ...);
    
    SomeClass c = new SomeClass();
    SomeFunction(c, param1, param2, ...);
    In Lua, OOP has been implemented the same way using tables, just that the "this"
    pointer we call "self"

    Code:
    local SomeClass = {}
    SomeClass.__index = SomeClass
    
    function SomeClass.SomeFunction(self, param1, param2, ...)
        ...
    end
    
    --[[
    The same as:
    
    function SomeClass:SomeFunction(param1, param2, ...)
        ...
    end
    ]]
    
    local c = setmetatable({}, SomeClass)
    c:SomeFunction(param1, param2, ...)
    -- The same as SomeClass.SomeFunction(c, param1, param2, ...)
    Basically, both comes down to:

    Code:
    SomeFunction(SomeClass& this, T1 param1, T2 param2, ...);

  5. #15
    Senior Member
    Join Date
    Mar 2007
    Posts
    766
    But that's cheating! That is the equivalent of calling C an object oriented programming language by passing structure pointers to functions and adding some syntactic sugar. How is inheritance and polymorphism implemented in LUA?
    Last edited by jeremic; 04-21-2014 at 08:49 PM.

  6. #16
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by jeremic View Post
    But that's cheating!
    well, it's tpforums :P

    Quote Originally Posted by jeremic View Post
    That is the equivalent of calling C an object oriented programming language by passing structure pointers to functions and adding some syntactic sugar.
    yeah, Lua uses the ':Func' as syntatic sugar for the '.Func(self, ' and speed up the OOP coding.

    Quote Originally Posted by jeremic View Post
    How is inheritance and polymorphism implemented in LUA?
    It's all about controling metamethods of the parent table. Basically, __index is the getter and __newindex is the setter function. There are more metamethods (aka methods to control its attached table) even to operator overloading like __add, __sub, __lt, __lt, __rt, __eq, __neq, ...

    I'm a Lua lover, even though I think that implementation is ugly as hell (without proper keywords and so on), but as the Lua author said Lua is meant to be built from the ground up just with the table data structure. Probably that's the reason he stickied this way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •