[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: New metamethod for method lookup
- From: TNHarris <telliamed@...>
- Date: Mon, 16 Nov 2009 20:50:59 -0500
On Mon, 16 Nov 2009 08:48:19 +0200
steve donovan <email@example.com> wrote:
> But any Lua programmer does expect this equivalence, it's as basic as
> p[i] == *(p + i) in C.
Just as it's expected for T:F() to do the same thing as T.F(T). Either
way, an assumption needs to be altered. And there's also the case of
wanting to call a variable method name. You wouldn't be able to do
> 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.
I'm less enthusiastic about the proposal today than yesterday. Perhaps
the difficulty with __index is to remind us that Lua is not an OO
language and we shouldn't be trying to make it one.
I'm also reminded how you can use __call for subscripting. Instead of
s['intersection'] you'd say s('intersection') and it doesn't step on the
toes of s.intersection.