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 
wrote:
> > 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:
> 	http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/hopl.pdf

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

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'