lua-users home
lua-l archive

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


On Jan 15, 2008 2:17 PM, Tomas Guisasola Gorham
<tomas@tecgraf.puc-rio.br> wrote:
>         I'm sorry being off-topic here but I can't understand why
> people start to fight using this list.  We have to believe the others
> are well-intentioned and are not attacking us.

Ah, yes! As Fabien says elsewhere, there is social aspect to
programming communities. As a colleague of mine says, people like
getting upset, even if there is no real provocation. This is not a
good thing, because people (especially those not used to us) might be
afraid to speak up because they could be seen as trolls!  I cannot see
why wanting a 'blessed' class system is being provocative at all, as
long as it does not _exclude_ any possibilities.

To get back on topic, this is moreorless the most frequent pattern for
class use:

Name = class()  -- 1. Some function!

function Name:method()
  ...
end

obj = Name()   -- 2 I like overloading () for this

obj:method()

1 and 2 are obviously 'style' issues, so I'm not pushing for any
particular standard here. But (a) methods are best defined using
qualified syntax (why do we _have_ to imitate Python?) and (b) are
called using the colon notation.

1 is just a function call. It usually creates a metatable, it might
not.  We could decide to directly populate the object with method
references; this can make a big difference as Thierry points out; it
depends whether speed is more important than memory.  The point is
that this implementation detail is totally encapsulated in the
function class(), provided we don't assume that every object must have
a metatable.  With a standard reflection interface, such details can
be safely hidden.

The point is that you can change how you do OOP just by changing one
function!  That's cool, although it is also scary.

I really think that providing a simple implementation of class() with
standard Lua would make a lot of new people more at home, immediately,
for the technical cost of 20 odd lines of Lua code.

The social aspect is more complicated. The Three Creators do not
include any blessed utility code; maybe they feel that would be too
prescriptive?  That it would upset people who already have their own
prefered solution? But those people know that they can continue using
their own solutions, that there isn't any implied value judgement of
their efforts.

What really is unnecessary, IHMO, are changes to the core, seeing that
the meta mechanism can produce such a rich set of solutions already.
That's something the mainstream 'competition' does not offer!

steve d.