lua-users home
lua-l archive

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


> 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.
Precisely.

> My guess would be that the cost of doing so is not insignificant
I can't see why: if we call either a.b.c.f() or a.b.c:f(), then a.b.c must have been resolved anyway - so, if I have it right, the only cost would be to push an available reference
onto the stack, wouldn't it?

> 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.
Why should it be to be more true for methods than for functions?
In the contrary, IMHO it would be even more natural for methods,
as we are used to consider calling a method as a kind of
"indexing something" (namely an object or class).

> 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.
My purpose is not to save a few keystrokes. It is mainly to get a cleaner,
more straightforward syntax, as it saves the need for an
extra operator (the : would simply disappear). A more generic syntax too, because it generalizes the use of only one concept. This in favor of a simplicity
principle (a.k.a. Occam's "do not multiply things beyond necessity")
-- and the design of Lua seems to extensively rely upon this principle.

It would also allow to stick to a more standard usage: most languages use a "." notation
to invoke a method -- see
http://merd.sourceforge.net/pixel/language-study/syntax-across- languages.html#bjcrntRflMthdnvct
The same usage in Lua would be more comfortable for those "programmers
dealing with multiple languages" you're talking about (and what programmer isn't nowadays?)

Best regards,
Serge