[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Need standard kernel supported class in Lua, was: Macros and expressivity
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Mon, 14 Jan 2008 17:39:42 -0500
Eric Tetz wrote:
> "LOOP [..] is a set of packages for supporting different models of
> object-oriented programming in the Lua language. [..] The models
> provided by LOOP are not intended to define a standard for the Lua
> language. Instead, they are examples [...]"
>
> It then describes 5 different OO models. I think your hypothetical
> newbie is going to go away more confused than ever. :)
>
> [...]
>
> For instance, C++ inheritance can be as simple as 'struct Foo : Bar
> {}', while at the same time allowing you to get progressively more
> complicated (multiple inheritance, interface inheritance, access
> control, etc.) without sacrificing performance.
C++ has structs, the dot syntax (which ends up being a syntactic sugar
over C symbols) and virtual method tables. Lua has tables, the colon
syntactic sugar, and metatables. That's all you need to do OOP. From
that you can build progressively more complicated models.
As you mentionned, LOOP implements 5 such models, and they are presented
as progressive refinements. Just use the simplest one until you feel you
need more features. At least that's the advice I'd give to someone
asking for Lua OOP on IRC.
> I also have to agree that the lack of a built-in model does tend to
> discourage OOP, at least at my workplace. If we're going to design
> our APIs in an OO manner, someone needs to design (or choose) the
> class mechanisms we will use. The path of least resistance is just to
> avoid it altogether or to have numerous ad hoc mechanisms in use.
Wouldn't the presence of a built-in OOP model encourage OOP ? Is that
desirable ? I personnaly prefer Lua as paradigm-agnostic, without
preventing users to use the paradigm they like.