lua-users home
lua-l archive

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

"Nick Trout" <> wrote:
>  ...Python was created with the intention of being a pragmatic
> scripting language. eg. its more OO 

As a base system, I'd agree because Python comes with classes, but Lua
allows you to more easily build a more OO system(a prototype-based instead
of class-based OO language) on top of it than you could in Python.

>(list and dictionaries accept methods)

Could you explain this a bit more?

> and its syntax is less "bodged" eg. "for" keyword instead of a function in 

I solved this problem for myself by writing a Collection(List) object that 
enumeration features.

> I know a lot of the functionality is
> duplicated and Lua itself admits to being a meta language which for me 
makes it
> slightly more complicated ie. less readable/simple! 

I agree. 

  local i, v = next(table, nil) 
  while ( i )
    i, v = next(table, i)

isn't as nice as Python's:

  for v in table:

or lua style:

  for i, v in table:

> I agree with this. Can you do inheritance with Lua? Copy an inherited
> class/table into the inherited class table?

Yes. In fact, that's all that Python does. Python classes are basicaly just
dictionaries with a few extra convenience methods. In Lua, you can also 
inheritance through delegation if you choose. I think this is covered in the
Lua FAQ.

I've implemented a prototype-based object system in Lua that uses delegation 

for inheritance. I could also put together a Python-like class system. If 
think you'd find these usefull, I could put them in a package and make them