Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lua Development Tools » unpack and table.unpack for Lua 5.2(table.unpack doesn't exist for Lua 5.2)
unpack and table.unpack for Lua 5.2 [message #1220815] Fri, 13 December 2013 18:40 Go to next message
nidal pres is currently offline nidal presFriend
Messages: 4
Registered: December 2013
Junior Member
I have just started using Koneki and have created new project and selected Lua 5.2 as a targeted execution environment.
All is fine for now, only when I use table.unpack() in my code I get this exception:

main.lua:31: attempt to call field 'unpack' (a nil value)


However, code completion shows unpack when I type table<dot> and when I hover with mouse over unpack() in table.unpack() it shows doc entry for table.unpack().

Changing table.unpack() with just unpack() does not create an exception.

Code that doesn't work:
function unpackit(tt)
	table.unpack(tt)
	for k,v in ipairs(tt) do
		print (k, type(v))
	end
end


and code that works:

function unpackit(tt)
	unpack(tt)
	for k,v in ipairs(tt) do
		print (k, type(v))
	end
end


So, is my project using 5.2 or 5.1?

Thanks!
Re: unpack and table.unpack for Lua 5.2 [message #1220949 is a reply to message #1220815] Mon, 16 December 2013 10:14 Go to previous messageGo to next message
Marc Aubry is currently offline Marc AubryFriend
Messages: 83
Registered: August 2012
Member
Hi Nidal,

As you used the Lua5.2 Execution Environment, your code is Lua5.2 compatible.
But, it seems you used a Lua5.1 interpreter to run your code (see how LDT manage interpreters in the documentation[1]). The interpreter by default is JNLua5.1, you can change it in the Launch Configuration as explained in the documentation[2].

[1]https://wiki.eclipse.org/Koneki/LDT/Developer_Area/User_Guides/User_Guide_1.1#Interpreters
[2]https://wiki.eclipse.org/Koneki/LDT/Developer_Area/User_Guides/User_Guide_1.1#Local_session

Re: unpack and table.unpack for Lua 5.2 [message #1221009 is a reply to message #1220949] Mon, 16 December 2013 16:31 Go to previous messageGo to next message
nidal pres is currently offline nidal presFriend
Messages: 4
Registered: December 2013
Junior Member
Oh, I see. I went on to Preferences->Lua->Execution Environments and ticked check box next to Lua 5.2, what I should have done is go to Preferences->Lua->Interpreters and tick check box next to Lua 5.2 there.

Now it works! Smile

Thanks!
Re: unpack and table.unpack for Lua 5.2 [message #1221408 is a reply to message #1221009] Tue, 17 December 2013 16:17 Go to previous message
Marc Aubry is currently offline Marc AubryFriend
Messages: 83
Registered: August 2012
Member
Just found an enhancement have been filed to set the Lua5.2 interperter by default while using Lua5.2 Execution Environment, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=397470.
Previous Topic:LDT 1.1RC2 and LuaDocumentor 0.1.3 are out.
Next Topic:Koneki LDT plugins
Goto Forum:
  


Current Time: Thu Nov 27 21:18:23 GMT 2014

Powered by FUDForum. Page generated in 0.02435 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software