lua-users home
lua-l archive

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

On Wednesday 13 September 2006 22:17, Luiz Henrique de Figueiredo 
> > I wonder why a new ':' operator was added?
> To provide support for object-oriented programming.
> See our paper on the evolution of Lua, section 5.2:

As I understood the original post, the question was not about the use 
or function of the operator, but rather why "self" isn't just passed 
all the time by the . operator or something, so that you don't have 
to worry about it when coding.

My guess would be that the cost of doing so is not insignificant, 
which makes it a bad idea for a language that isn't OOP-only. Also, 
using : instead of . at least serves as a hint that you're not *only* 
indexing something to get your function, which I believe is a good 
thing. (Languages with lots of implicit side effects, default actions 
and whatnot tend to be very easy to misread, especially for 
programmers dealing with multiple languages. IMNSHO, it's just not 
worth it to save a few keystrokes here and there.)

//David Olofson - Programmer, Composer, Open Source Advocate

.------- - Games, SDL examples  -------.
| - 2.5D rendering engine       |
| - Music/audio engine          |
| - Real time scripting         |
'-- - Rheology instrumentation  --'