lua-users home
lua-l archive

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


It was thus said that the Great Dirk Laurie once stated:
> 
> My conceptual objection is that the base library should not be
> targeted to the special needs of people who need metamethods
> to the point of inconveniencing those who do not. That stuff
> can go into the table library, which has a long history of being
> misunderstood if not disliked by many and seems destined
> to continue in that great tradition.

  I rely upon metamethods.  A lot.  But not on tables.  I use a ton of
userdata objects in my code (5.1, mainly to keep the ability to use LuaJIT
if I have to at work).  Putting this stuff into the table library won't be
of much use to me.

  Now, __pairs or __ipairs don't exist in Lua 5.1 and of the two, I regret
not having __pairs.  I can work around __ipairs with

	for i = 1 , #userdata do ... end

__pairs, not so much [1].

  -spc 

[1]	Okay, I can work around it with a very clumsy:

		udindex = { 'foo' , 'bar' , 'baz' }
		for _,idx in ipairs(udindex) do
		  local item = userdata[idx]
		  ...
		end