[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Recognizing Methods vs. Functions
- From: "Nick Trout" <nick@...>
- Date: Mon, 15 Dec 2003 14:11:16 -0800
> You're right. I'm trying to write a class structure, and want to have
> functions that are callable from the class description rather than the
> instance.
>
> But I just realized that Lua doesn't have to keep track of this
> information
> after compile so there's nothing to look for.
That's because it's not really a language feature but a syntactic
"sugar", so that's where the support ends. People often bitch in Python
that the explicit declaration of "self" is an annoyance, but it does
make the code clearer when methods in self are called, as you must use
self.method(), i.e. you know which scope you are calling. In C++ "this"
is always defined regardless of calling convention or declaration style.
Lua is in an awkward spot somewhere between. Personally I think its
better to explicitly declare self in your function definition ('.'
syntax) and only use the ':' syntax for calling.
Nick