Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 May 2006
Offline Last Active May 12 2012 05:37 AM

#4938641 Clean lua stack

Posted by on 09 May 2012 - 05:53 AM

If you are determining that the stack is not empty via the return value of lua_gc then you are mistaken. The stack is not the only place when memory is used and a separate stack space is given to each C function which Lua calls, for instance there is _G the global table or _ENV the environment table in 5.2 (of which there can be many) and also the registry. Added to this a variable which is on the stack and also stored in another place will not be collected.

Rest assured your stack is empty and after such a time that there are no more references to the data, without you doing a gc (never mind 10), the memory will be released.

#4930200 Why LUA Script ?

Posted by on 11 April 2012 - 04:53 AM

the downvote button is for not agreeing with someones opinion.

Congratulations, you have earned the award of being downvoted by me again.
Grow up, I sent the private message to explain the reason and to tell you it was me that downvoted you please do not use private messages to insult me.

#4930063 Why LUA Script ?

Posted by on 10 April 2012 - 07:12 PM

Oh, and the documentation isn't always that helpful, for instance, lua_pcall(L, NumArgs, numRet, 0) when I first started using it I had my numArgs being the number of arguments the function needed, the documentation didn't specify specifically that the function call was also an argument, so it was failing on me. The documentation wasn't wrong, it just wasn't helpful enough for an impatient tiered student as of myself find understand it how it was meant to be.

Take no notice of this, Lua's documentation is excellent.

falconmick maybe you should read the documentation next time it clearly tells you the protocol as lua_pcall links to lua_call

As people are mentioning the speed of Lua compared to C and C++, if this does become a problem you can always you use the excellent and blazingly fast LuaJIT which supports quite a lot of platforms now with speed being the same or close to C code.

edit: I just can not let it go :) The Language's name is Lua not LUA,

#4923779 Pointer from C++ to Lua/Tolua++ as an argument.

Posted by on 20 March 2012 - 05:49 PM

"Lua" (pronounced LOO-ah) means "Moon" in Portuguese. As such, it is neither an acronym nor an abbreviation, but a noun. More specifically, "Lua" is a name, the name of the Earth's moon and the name of the language. Like most names, it should be written in lower case with an initial capital, that is, "Lua". Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!


#4923061 Alternative to singleton

Posted by on 18 March 2012 - 10:44 AM

Is a constructor with over 50 arguments 'better code'?

No it is a code smell that could indicate the class is doing too much.

#4861010 Lua send reference to C++ class to another class

Posted by on 13 September 2011 - 03:28 AM

Firstly when ever I hear a type which has "manager" as part of it's name, my first reaction is always you are doing it wrong.

It sounds like what you want it a Lua reference [1] yet you have to take into account that this reference by default will keep the object alive.

[1] http://www.lua.org/manual/5.1/manual.html#luaL_ref

#4853678 Bug in visual c++ 2010 with standard conforming code.

Posted by on 25 August 2011 - 09:16 AM


Issue created on connect, it would have been nice if the OP updated the post to reflect this.

#4843475 Lua Helper/Wrapper

Posted by on 02 August 2011 - 03:13 AM

I know of a certain library I like which has the syntax helper.call("funcname","param1",int2) :)
There have also been a number of new libraries released lately which are said to be simple wrappers such as Lua_icxx and Lua Wrapper. Failing all that see the Lua wiki for a list of binding libraries.

#4843474 Remove an object from the lua state! Click to flag this post

Posted by on 02 August 2011 - 03:02 AM

I am not too familiar with Luabind's policies yet I would look at adopt, it depends on how the data is stored internally by Luabind but you could (this sounds like the wrong solution here) just nil the entry in Lua.

By the way why does your thread title contain "Click to flag this post"?

#4835242 [Lua/C++] Table of closures

Posted by on 14 July 2011 - 07:42 AM

"This isn't my exact code but it does pretty much the same thing" Please post the actual code or code which displays the problem as this code is fine.

"I believe the reason for this is because the stack is supposed to be arranged with the key before the value" That is what the stack looks like in your example.

#4821891 Lua heap corruption

Posted by on 10 June 2011 - 04:20 PM

I am not currently on windows so I would ask that you please post this problem to the Lua mailing list [1] where the authors and others will see it and be able to respond. I personally do not understand why checking for 50 stack entries would return true then fail, whilst check for a single empty stack space at every iteration would succeed.

[1] http://www.lua.org/lua-l.html - requires sign up.

#4795489 Lua/C Calling lua function from C, with table parameter

Posted by on 07 April 2011 - 06:24 AM

If people who knows how to do it explained to you how to do it right away (saving you hours of having to figure it out by yourself) the value of their lives would drop considerably because knowing that is mostly all they are worth.

'saving you hours' See this is the problem, force feed me information without me having to lift a finger as I am so lazy.
The OP did not ask the question in a way which would be considered smart and also has information missing. How I interpret this is that the OP wants information force feed and this will not stop until the cycle is stopped in addition they also consider their time more important than mine as they can not be bothered to look for the information instead the first action is to ask.
If there is not an answer to questions about Lua in PiL or the manual or if you have at least looked and can not find the information then I would personally be more forth coming with answers. As it happens both the links posted (which the OP should really have read first) give the 'right way' of doing what was requested and now at least the OP will now where to look for the information.

Who do you think told everyone else how to use Lua?

OP: Let me know if you figure it out, I'm interested in knowing this too.

Well RTFM or ask questions and provide information showing you have at least made an effort to find the data.

Never assume you areentitledto an answer. You are not; you aren't, after all, paying for the service. You will earn an answer, if you earn it, by asking a substantial, interesting, and thought-provoking question one that implicitly contributes to the experience of the community rather than merely passively demanding knowledge from others

#4791914 Lua book/tutorial

Posted by on 29 March 2011 - 03:57 PM


It is Lua!!

GPG 6 & 7 both have Lua binding articles in them, where 6 is written by the Lua development team.

svetpet there is the free first edition of Programming in Lua and the second edition for 5.1 available from the Lua website.

Lua runs slower but takes very little time to code

True but you can get near and sometimes the same performance by using LuaJIT2, more specifically FFI.

#4787659 Lua/C++: Keeping the index of a function/table after calling lua_getglobal so...

Posted by on 18 March 2011 - 02:10 PM

Clearly I am doing something wrong...

Clearly you are and I am a little confused after you said this only yesterday

I personally don't want my engine's c++ code all interleavedly mixed up with Lua API calls.

Why can't you do this with SWIG?

SWIG automagically generates all the required c/c++ code needed to share whatever you need with Lua scripts

So instead I will just say RTFM.

#4779814 What are unions good for?

Posted by on 27 February 2011 - 02:32 PM

A common use is to lay out a friendlier structure over the top of a larger type which facilitates, for example, SIMD operations, a'la:

struct Vec4{
    union {
        __m128 v;
        struct { float x, y, z, w; };

Can people stop posting this crap as if it is defined, or at least state that it is platform specific. Ravyne has taken this to another level filled with even more undefined/illegal goodness, requiring language extensions.
Maybe this is should be in the FAQ.