lua-users home
lua-l archive

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

> Just in case I was unclear:
> table::function() passes no implicit self and would be the same as:
> methods(table).function()
> table->function() passes an implicit self and would be the same as:
> methods(table):function()
> That's all there is to it.  The use of the :: and -> operator is just to
> mask the methods(table) lookup.
> I am unsure exactly of what you were asking, but the :: operator is like
> the C++ :: operator and the -> operator is like the C++ . or ->
> operators.

I see.  I guess that illustrates how hard it can be to understand a lot of
interrelated syntaxes.

I was thinking that just by extending the Lua syntax
table::function() -> methods(table):function()
That way the new colon syntax is related to the old mnemonically.  From the
C++ perspective your way makes sense, but I don't think asking people to
remember syntax with reference to C++ is a good thing.

Too bad .. is concatenation or you could use t..x and t::x to mean
methods(t).x and methods(t):x respectively.