lua-users home
lua-l archive

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


On Mon, Nov 16, 2009 at 1:13 AM, TNHarris <telliamed@whoopdedo.org> wrote:
> What about dot syntax?. I'd expect set.intersection to not be the same
> thing as set['intersection'] in the object you describe.

But any Lua programmer does expect this equivalence, it's as basic as
p[i] == *(p + i) in C.

> There's too many surprises if colon and dot did different things. And this doesn't
> have to be limited to functions, so calling it "method indexing" would
> be inexact.

This is the part that worries me.  We have a very simple mechanism,
which still takes a little while to 'get' if you're new to it. Adding
another layer of lookup may confuse people?

Also, anything done to something as basic as method lookup must not
hit performance.

But we do have an generally awkward situation when trying to 'override
the index operator' on metatable-based objects. MT.__index is MT, so
we have to give MT its own MT (MMT), and make MMT.__index catch any
unresolved lookups.

steve d