[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why a : (colon) operator?
- From: Oemii <oemii@...>
- Date: Thu, 14 Sep 2006 01:50:41 -0400
> 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
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
onto the stack, wouldn't it?
> Also, using : instead of . at least serves as a hint that you're
> indexing something to get your function, which I believe is a good
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
more straightforward syntax, as it saves the need for an
extra operator (the : would simply disappear). A more generic syntax
because it generalizes the use of only one concept. This in favor of
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
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?)