lua-users home
lua-l archive

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


On Tue, Nov 17, 2009 at 3:50 AM, TNHarris <telliamed@whoopdedo.org> wrote:
> 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.

Similar feelings here.

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

Now that has promise as a notation!  (Also, as lhf points out, you can
have multiple array indices and it looks just like Fortran)

But, s("intersection") = true won't fly, alas.  Has to be
s:add("intersection") or something like that.

A general observation: making objects callable all over the place can
make debugging somewhat difficult. For instance, it pleased me at one
time to have s(i) meaning 'i th character of the string s' but passing
around callable strings caused odd error messages - we often depend on
simply being told, 'look you have not passed me a function'

steve d.