lua-users home
lua-l archive

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

>>> 01/27/05 05:05AM >>>
>I'm impressed with the ideas that came up on the subject OOP in Lua.
But most (if >not all) of them lack a clear syntax in on place or
another. I need a simple, clear >syntax so users of my apps can extend
it without much trouble.

What would be cryptic about this style?  It's very
straightforward to implement:

  Animal = class()

  function Animal:init(name)
  = name

  function Animal:to_string()

 Dog = class(Animal)

 function Dog:sound()
    return 'bark!'

>Am I asking for syntatic sugar? Yes, sure! 
It's easy to make simple lexical
substitutions, like '@' for 'self.'
If there was some way to flag a function as
being a method, then that explicit ':' could
just be a '.'  There's an interesting

steve d.