[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: New metamethod for method lookup
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 16 Nov 2009 08:48:19 +0200
On Mon, Nov 16, 2009 at 1:13 AM, TNHarris <email@example.com> 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
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