lua-users home
lua-l archive

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


* steve donovan:

> 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.

Except that most C programmers are surprised by this---and that they
can actually write i[p], too. 8-)

I think Lua's uniform lookup rules have their issues (as pointed out
in this thread, adding methods to objects which support arbitrary keys
for indexing is not possible, for instance).  But as an advantage, it
is possible to actually describe the lookup rules.  I have yet to find
such a description for Python's attribute lookup rules (those
complexities do not come from the key/attribute distinction
exclusively, but I guess one thing led to another, and now the whole
thing is quite impenetrable).  I'm not saying that Python's data model
is bad; you can write some constructs very concisely and clearly, but
at the cost of a rather complex (and slow) underlying lookup process.