lua-users home
lua-l archive

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


On Wed, Sep 29, 2010 at 15:26, Christopher Eykamp <chris@eykamp.com> wrote:
>
>> There are no confusing similar concepts. Dot is "get value" and
>> colon is "call". Easy to grasp, isn't it?
>
> But dot also means call.
>
>

It's a matter of perspective. Both retrieve the value; one returns it
(and you might immediately call afterward); the other is only valid if
you're calling it in the same expression.

I like the idea myself of declaring a function differently such that
the 'self' parameter is automatic without needing to use a colon.
However it has some potential ambiguity:

a={}
method a.b() print(self) end
a.b() --should print the address of a
n = a.b
n() --???
c = {b=a.b, d=a.b, e=n}
c.b() --prints a, or c?
c.d() --prints a, or c?
c.n() --???

My guess would be n() would print nil and all of the last three would
print the address of c, but I don't think the specification clarifies
these cases, which means implementations could vary.

-- 
Sent from my toaster.