lua-users home
lua-l archive

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


On Fri, Apr 15, 2011 at 1:32 PM, H. Diedrich <hd2010@eonblast.com> wrote:
>  Coming from C++ you'll see some
> of the safety but also lots of clutter from the hard types flying off. That
> to my experience, needs a little stretching to allow oneself to put the
> liberty to task. But Lua absolutely deserves to try to free your mind from
> what you know, with an effort, which is harder because it looks so similar.

This is very true, treat it first as a new game, and come back to the
old OOP strategies when they make sense.  In particular, the whole
idea of _closures_ (especially anonymous ones) is so liberating.  A
common pattern in modern C++ is to use 'functors', objects which are
callable, because classes are The Way to encapsulate state; a closure
can often do the job much more cleanly.

That being said, if I had some objects which were Drawable, I would
use OOP-like thinking, but would only bother to define a Drawable
common base class if these objects did indeed need to share some
common implementation.

steve d.