An object system in 5 LoC

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

An object system in 5 LoC

Eduardo Ochs
Hello!

This is an announcement for the latest & greatest version of my OO
system for Lua: "eoo.lua", at:

  http://angg.twu.net/dednat5/eoo.lua.html
  http://angg.twu.net/dednat5/eoo.lua

Its core, in 5 lines of code, hasn't changed since the last release,
but now its documentation has fantastic box drawings,

  http://angg.twu.net/dednat5/eoo.lua.html#box-diagram

and you are all
now urged to add great box drawings to your OO schemes too!

  Cheers =),
    Eduardo Ochs
    [hidden email]
    http://angg.twu.net/



P.S.: This list used to have a very high signal-to-noise ratio, and
used to be very friendly... I am not going to complain - but that's
just because complaining is not going to be useful right now. This
message is an attempt to throw a bone to the dogs to distract them a
bit.

P.P.S.: it my (obsolete?) opinion this list should be more receptive
to messages like this:
  http://lua-users.org/lists/lua-l/2011-11/msg00714.html
and less tolerant with whinings, complaints, and aggressive jokes.

Reply | Threaded
Open this post in threaded view
|

Re: An object system in 5 LoC

Stefan Reich
On Mon, Nov 21, 2011 at 1:47 PM, Eduardo Ochs <[hidden email]> wrote:
Its core, in 5 lines of code, hasn't changed since the last release,
but now its documentation has fantastic box drawings,

Hehe. Great. And yeah, please show us examples, I am very curious to see that.

P.P.S.: it my (obsolete?) opinion this list should be more receptive
to messages like this:
 http://lua-users.org/lists/lua-l/2011-11/msg00714.html
and less tolerant with whinings, complaints, and aggressive jokes.

Yes it absolutely should. Thanks for pointing this out, I am quite happy to see that.

In other news, I am planning to create a new list as I'm not sure if lua-l can be cured of its attitude problems. Maybe it can, maybe it can't.

Making a new list is probably the smartest way to solve the whole problem.

Stefan
Reply | Threaded
Open this post in threaded view
|

Re: An object system in 5 LoC

William C. Bubel
In reply to this post by Eduardo Ochs
On 11/21/2011 08:47 AM, Eduardo Ochs wrote:

> Hello!
>
> This is an announcement for the latest & greatest version of my OO
> system for Lua: "eoo.lua", at:
>
>   http://angg.twu.net/dednat5/eoo.lua.html
>   http://angg.twu.net/dednat5/eoo.lua
>
> Its core, in 5 lines of code, hasn't changed since the last release,
> but now its documentation has fantastic box drawings,
> ...

Looks good, though I have a couple of practical questions about it. A
common idiom in OOP is polymorphic overriding of functionality, that
involves making a chain of calls back to the base class. In a Object ->
Sprite -> Monster tree of inheritance, this kind of thing would happen:

function Monster:foo(x, y, z)
  Sprite.foo(self, x, y)
  self.z = z
end

function Sprite.foo(x, y)
  Object.foo(self, x)
  self.y = y
end

function Object.foo(x)
  self.x = x
end

Is that how you would recommend doing it in your object system?