lua-users home
lua-l archive

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



On 22 Jan 2010, at 19:47, Patrick Donnelly wrote:

That being said, I wonder, which one is better and why... What do you think?

So to answer your question, neither :)


I agree with Patrick here. However I'd go a little further and vote for no 'table.pack' at all. I agree it is useful in some cases and people write something like that often (as does 'string.split', 'table.append', 'table.copy', ...). But I don't believe there is one- version-fits-all to make it into a standard library. Furthermore, the asymmetry with 'table.unpack' [1] and bringing back the 'n' field policy does not look like the best choice either. Personally, I'd rather see 'apairs' [2] becoming standard.

Whenever possible, the Lua team avoided the introduction of new features or standardization of policies and particular solutions. This should be easier now with Lua's package model that promotes the use of third-party libraries to fulfill particular needs. That's why the standardization of 'bit' and 'table.pack' came as a surprise to me.

[1] http://lua-users.org/lists/lua-l/2010-01/msg00414.html
[2] http://lua-users.org/lists/lua-l/2008-06/msg00268.html

--
Renato Maia
Computer Scientist
Tecgraf/PUC-Rio
__________________________
http://www.inf.puc-rio.br/~maia/