[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Cryptic OOP syntax
- From: André de Leiradella <leiradella@...>
- Date: Sat, 29 Jan 2005 14:30:05 -0300
>What do you mean by "putting OOP in the core"?
Having native support to OOP in Lua:
self.name = name
class B extends A
b = new B('me')
>Lua already has the polymorphism aspect of OOP fairly well handled.
>Inheritance is handled fairly cleanly in most of the OOP implementations for
>Lua so long as you don't want to make calls up the inheritance chain (i.e.,
>you don't care about super). Super calls can be handled just like in C++ and
>Python and those pass OOP muster with at least some people, so even this may
>be a non-issue.
Inheritance is what separates structures from classes. You can declare a structure, alloc an instance of it in memory and do things like obj->toString(obj).
>Encapsulation is complicated to achieve. There are work arounds (I posted
>one to the Wiki this morning), but none of them are perfect. But
>encapsulation is arguably more about modularity than it is about OOP. For
>example, my ideal answer to encapsulation would probably be to introduce
>some form of private key declarations within modules together with ways to
>keep them private.
I agree it's more about modularity, but it's important in OOP to hide the implementation of the class and, most important, keep users out of trouble. Just telling them to not touch some properties is not enough in my opinion.
Andre de Leiradella