Any arguments passed away to the features get as added arguments to coroutine

Like coroutine.create , the coroutine.wrap work furthermore brings a coroutine, but alternatively of returning the coroutine itself, they return a function that, whenever labeled as, resumes the coroutine. resume . coroutine.wrap returns every standards came back by coroutine.resume , except the initial one (the boolean error code). Unlike coroutine.resume , coroutine.wrap cannot find problems; any mistake is actually propagated on caller.

This part describes the C API for Lua, this is certainly, the collection of C functionality accessible to the host regimen to communicate with Lua. All API features and related type and constants were proclaimed from inside the header document lua.h .

Even when we use the term «function», any facility inside the API could be supplied as a macro rather. All these types of macros make use of every one of their particular arguments just as soon as (except for 1st discussion, that’s usually a Lua state), therefore cannot create any undetectable side-effects.

As in more C libraries, the Lua API functionality cannot search their unique arguments for validity or reliability. However, possible alter this conduct by putting together Lua with an effective description for all the macro luai_apicheck , in file luaconf.h .

3.1 The Stack

Lua uses a virtual bunch to pass principles back and forth from C. Each take into account this bunch shows a Lua price (nil, wide variety, sequence, etc.).

Whenever Lua phone calls C, the known as function will get another bunch, in fact it is independent of past stacks and of piles of C performance which can be still energetic. This stack in the beginning consists of any arguments with the C features which is where C function pushes the results to be gone back to the person (read lua_CFunction ).

For convenience, more question businesses when you sprГіbuj internetowej look at the API dont stick to a tight bunch self-discipline. Instead, they’re able to relate to any take into account the heap simply by using a directory: a confident list presents a total pile position (starting at 1); an adverse directory shows an offset in accordance with the top of the heap. Much more specifically, when the bunch provides n aspects, then directory 1 represents the most important aspect (that is, the factor that was pressed on the heap earliest) and list letter symbolizes the past element; index -1 also presents the very last factor (that will be, the element towards the top) and list -n presents the first element. We claim that an index was valid whether it consist between 1 therefore the bunch very top (definitely, if 1 a‰¤ abs(index) a‰¤ very top ).

3.2 Heap Size

Once you connect to Lua API, you happen to be accountable for making sure consistency. In particular, you’re responsible for controlling stack overflow. You need to use the big event lua_checkstack to cultivate the pile dimensions.

Whenever Lua calls C, they helps to ensure that no less than LUA_MINSTACK heap positions can be obtained. LUA_MINSTACK is described as 20, making sure that generally you don’t have to worry about pile room unless your rule enjoys loops moving areas on the stack.

Many query functions take as indicator any advantages within the readily available pile room, definitely, indices to the utmost bunch size you have set through lua_checkstack . Such indicator have been called appropriate indicator. Considerably previously, we establish a reasonable index below:

3.3 Pseudo-Indices

Unless or else mentioned, any work that allows valid indices can be labeled as with pseudo-indices, which portray some Lua prices that are accessible to C code but which are not in pile. Pseudo-indices are used to access the bond environment, the function surroundings, the registry, plus the upvalues of a-c purpose (see A§3.4).

The thread conditions (in which global variables reside) is obviously at pseudo-index LUA_GLOBALSINDEX . The surroundings in the running C function is definitely at pseudo-index LUA_ENVIRONINDEX .

Prev My professional tasks are efficiently enabling men avoid intimate acting-out behaviors
Next 8. The guy Appears When you really need Let

Leave a comment