[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Colon notation in object-oriented programming
- From: Francisco Olarte <folarte@...>
- Date: Sun, 5 Mar 2017 18:51:00 +0100
On Sun, Mar 5, 2017 at 3:01 PM, Viacheslav Usov <via.usov@gmail.com> wrote:
> Fact is, the difference between the dot and the colon is very confusing and
> much back-stabbing for Lua neophytes, especially for those with experience
> in other object-oriented languages, where the dot means exactly what Lua
> denotes by the colon. Such people tend to make this mistake even after years
> of using Lua, if it is not their primary language.
My problem with colon is that, being used to languages which use dot
for everything, I routinely end up writing obj.method(a,b,c), which is
perfectly legal lua ( and luacheck ) and ends up producing tedious to
debug runtime errors later on.
I'm used to languages which separate 'methods' and data, like C++ (
which, both being statically typed can do the proper thing with the
dot depending on the decl ) or even perl ( where you do
$obj->method(...) or $obj->{function}->(...) ), and it bites me every
single day. I alleviate it by grepping periodically on the source (
for '\w+\.\w+\(' ) and stashing the rarely used function call in
locals ( obj:method(), but local f=obj.func; f(...) ), but is one of
the major pains I encounter when doing moderately complex code in lua.
Regards.
Francisco Olarte