[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Cryptic OOP syntax
- From: "Steve Donovan" <sjdonova@...>
- Date: Thu, 27 Jan 2005 10:08:39 +0200
>>> leiradella@bigfoot.com 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)
self.name = name
end
function Animal:to_string()
return self.name..self:sound()
end
Dog = class(Animal)
function Dog:sound()
return 'bark!'
end
>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
project!
steve d.