Wednesday, April 18, 2012

error : function has more than 60 upvalues

Hello,

first escuse me for my english, i'm french :)

I tried tu update arcanum mod adding the new portal and teleportation spell.

I don't know LUa but others languages.

The error is Interface\AddOns\Arcanum\Arcanum.lua:4822: function at line 3614 has more than 60 upvalues.

Anyone can help me ? What this error meaning ?

Thanks.

Kirika|||What is line 3614?|||Quote:








What is line 3614?




it's function function Arcanum_CreateMenu(). I had 2 more button in the interface and add code in it.|||Quote:








it's function function Arcanum_CreateMenu(). I had 2 more button in the interface and add code in it.




Well, i think i found the problem. Just have to resolve it :)

Sorry for this post, I past more than 1h trying to find the probleme and after posting I find it :(

Seem i use to create more than one button at the same position. But i still don't know why i 'm this error message.

I will check it and come back here|||Upvalues are something to do with nested functions, I'm not sure exactly what it means though.|||upvalues for dummies - (which includes me by the way)



In oversimplified terms you can categorise variables in to three different kinds :

Global

Local

&

Upvalue <- otherwise known as External Local Variable which is a much better name




Code:

var1 = 1;

local var2 = 2;

function smackMyValueUp()
local var3 = var1 + var2;
print( var3 );
return var3;
end

var1 is global

var3 is local

but

var2 is an external local variable when referenced within the function smackMyValueUp

i.e. var2 is an upvalue from the point of view of smackMyValueUp



Basically, if your function makes too many references to variables that are not global, but which are defined outside the scope of the function - then it will fall over; I think the default value is 60.



Memory storage of these types of variable have to be dealt with as special cases by LUA, as they are neither truly global, nor truly local to the function....

Tunga is correct in that nesting lots of functions inside each other can lead to the same problem, because all the local variables declared by the outer functions are available to be accessed by the inner most function, and are therefore upvalues.



If you want a proper explanation then check out the section on Closures in :

Programming in LUA : 6.1 - Closures



Edit: function names are variables like any other|||Ah that makes sense, great description :) .

From a technical point of view (I didn't actually check the link yet) I'm guessing this is due to having to pass those variables via a call stack or similar.|||Quote:








Ah that makes sense, great description :) .

From a technical point of view (I didn't actually check the link yet) I'm guessing this is due to having to pass those variables via a call stack or similar.






Yup, I think it uses pseudo-indices to point at values that aren't on the stack or something...

But as I mentioned, my explanation really was gross over simplification, and the functionality enabled by Closures is the real reason that upvalues are handled that way, so the link above is worth looking at|||I found time to read it, that page makes a lot of sense and is good for understanding a bit about how Lua is really working behind the scenes. Great link, thanks :) .

No comments:

Post a Comment