lua-users home
lua-l archive

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


> On 14.7.2017, at 23.40, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> Hmmm, you are comparing Lua with a statically typed language C which
> is not a valid comparison. In C, the kind of OO I am talking about is
> prevalent - such as take stdio. The FILE* is the object. Because of
> static type checking a function call syntax works fine. In Lua, this
> is errorprone as it is a dynamic language - so an API that asks users
> to say file:write() helps the user to avoid mistakes.

In practice I've not found ':' to be any less error prone. It's easy to accidentally type '.' in its place so you are trading one mistake for another.

In practice though, after you have dropped the magical self notation and start thinking outside the realm of objects and classes, you began to wonder why you ever needed ':' in the first place. It begins to feel very artificial to have one biased function arg when you really just have functions operating on its args. Also not needing to shoehorn every operation into a class, was a real eye- opener for me.

Petri