lua-users home
lua-l archive

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

Ico wrote:
* On 2009-12-20 frank <> wrote  :
Giving back the table as return value from table.insert would:
 - enable "sometable=table.insert(sometable or {},newelement)"
 - not break existing code
 - probably not significantly impact performance

So, why not?

I guess the other 'logical' behaviour would be to return the newly
inserted element instead of the table:

  thing = table.insert(sometable, new_thing())

Maybe neither is implemented because they're both equaly logical ?

Even without arguing which possibility feels more natural, if the
performance impact is as low as I imagine (very nearly none) then
it would make sense to return whichever instead of neither.

So I submit to establish the feasibility to return a value first,
and commence the argument over what should be returned second... =)

Regards, Frank