lua-users home
lua-l archive

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


On 04/10/2014 08:46 PM, duz wrote:

I'm sorry, but I still don't see why it is so important to
throw away any values here. Why is __index it in 2.4 defined to

   return (h(table,index))

instead of just

   return h(table,index)

which I'd find good uses for.


This has been answered before:
On 04/10/2014 09:50 AM, Tim Hill wrote:
On Apr 10, 2014, at 12:45 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

2014-04-10 9:06 GMT+02:00 duz <duz@sol-3.de>:

Please do not truncate the results returned from __index to 1!
I'll support that, for now, until somone demonstrates the unpleasant
side effects this might have.

local a,b = tracker[1]

Seems ok to me, but i’d be worried about:

foo(tracker[1])

Passing extra values into a function unexpectedly.

—Tim



This argument is currently enough reason for me to keep it as it is. Otherwise you would see a lot of foo((tracker[1])) in Lua code. I once thought that adding an additional return value to an existing function is a harmless change, it isn't. I learned that the hard way.
--
Thomas