lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>> leiradella@bigfoot.com 01/20/05 05:47AM >>>
lua-bounces@bazar2.conectiva.com.br wrote:
> Here is an Objective-C example on how to add "behavior" to another
> class. In a nutshell, a class in Objective-C is simply a structure
> holding methods (aka functions). You can therefore easily move
methods
> (aka "behaviors") from one class to another. So instead of (ab)using
> inheritance, one is more likely to use "composition".
> 
>*Too way* complicated...

Ah, what I liked about Lua is that it's so simple and
elegant compared to C++ - away with the 
straightjacket!  So Objective C idioms are interesting;
to _move_ a method from one class to another in
Lua is just an assignment, but you need _some_
guarantee about the new self in that case.

For example, a method that expects
its object to quack is not going to work on
anything except a duck.

There are performance constraints on any
OOP implementation. E.g., top of my head;  it
would not be difficult to implement properties
transperantly, via __index looking for accessor
functions called 'get_<name>' etc.  But that
makes at least property access a good deal
slower than a plain method call.   That
may well be acceptable in many cases,
but not all.

steve d.