lua-users home
lua-l archive

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

Gavin Kistner skrev:
class BonusAccount, Account do
	function getBalance()
		print("BonusAccount.getBalance()", self.balance * 1.2)
		return base.getBalance() * 1.2

Any o(pi)nions?!
I probably wouldn't use this myself becuase I have my own class system that I use. However, since you asked for opinions:
1) I don't like the 'do' keyword there. Function definitions don't have one, so why have one for classes?

2) If you're modifying syntax, I personally prefer Ruby's syntax for showing inheritance during class definition:

class Foo < Bar

What you have there looks like you're defining two common classes at once or something.

3) endclass? Feels like a very hacked-on approach. 'end' is the way to go, if you could make it happen.

This was exactly the kind of opinions asked for.

The "do" is actually quite easy to get rid of.. Thanks.

thought about having

class Foo inherits Bar

but comma was less to type.. colon might've been more clear to use, or less than for that matter :)

It is a very hackish implementation this far, simply because it was the easiest way to get it done fast since I didn't have a clear picture of how I wanted it to be from the get go.

I had end instead of endclass at first, but the I have to keep track of all code inside the class to know when an end means the end of the class and not a function inside the class, which isn't that hard to do, but it was easier to introduce a new "keyword" for it.