1

Topic: Reset of errors in Lua, how?

Hello! I did not understand Something how to return errors in Lua from C-shnyh functions? As I understood, the number which is returned C-shnaja by function is an amount of returned values,  in a stack. Dug out int lua_error (lua_State *L); int luaL_error (lua_State *L, const char *fmt...); Generates a Lua error, using the value at the top of the stack as the error object. This function does a long jump, and therefore never returns (see luaL_error). But here something is not pleasant to me selected - I at me  the project, any  jumps are not necessary to me. I need to return an error so that Lua stopped operation and returned an error in that code, the interpreter whence was caused. Tried to return from  functions the negative values - Lua continues to work, and  about an error only if this result is used further: some_fn () - works someVar = some_fn () message ("Result:". someVar, 1) - here an error [string "..." ]:3: attempt to concatenate a nil value (global ' someVar ') How to be?

2

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: M> How to be? To use lua_error, only so. lua all the same it at itself inside uses.

3

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: M> How to be? To use lua_error. Thus to collect lua as a C ++ library, instead of a C. Then lua will use exceptions instead of longjmp. Ubuntu See https://www.lua.org/source/5.3/ldo.c.html, for example, delivers two versions  -  and . It is necessary only  with necessary. If itself you collect enough to compile it  the compiler, instead of . Here itself look, how it to achieve (files lua to rename in.cpp, for example).

4

Re: Reset of errors in Lua, how?

Hello, LuciferSaratov, you wrote: M>> How to be? LS> to use lua_error, only so. LS> lua all the same it at itself inside uses. Yes, it is similar to that. Invented a pancake , is not present that return codes to make or any status to install in lvm

5

Re: Reset of errors in Lua, how?

Hello, andrey.desman, you wrote: M>> How to be? AD> to use lua_error. AD> Thus to collect lua as a C ++ library, instead of a C. Then lua will use exceptions instead of longjmp. AD> Ubuntu See https://www.lua.org/source/5.3/ldo.c.html AD>, for example, delivers two versions  -  and . It is necessary only  with necessary. AD> if itself you collect enough to compile it  the compiler, instead of . Here itself look, how it to achieve (files lua to rename in.cpp, for example).  itself. Made through lua_error. Basically, as I see, the main thing that automatic objects with nontrivial  on a stack were not. Or still any problems can be?

6

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: M> Kompilju herself. Made through lua_error. Basically, as I see, the main thing that automatic objects with nontrivial  on a stack were not. Or still any problems can be? I speak, collect it as  the code and problems with  any will not be. Generally any will not be.

7

Re: Reset of errors in Lua, how?

Hello, andrey.desman, you wrote: M>> Kompilju herself. Made through lua_error. Basically, as I see, the main thing that automatic objects with nontrivial  on a stack were not. Or still any problems can be? AD> I speak, collect it as  the code and problems with  any will not be. Generally any will not be. I understood it. But I already and with  a variant normally made, and to alter laziness

8

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: M> I understood It. But I already and with  a variant normally made, and to alter laziness??? The same simply question of compilation, instead of the code.

9

Re: Reset of errors in Lua, how?

Hello, andrey.desman, you wrote: M>> I understood It. But I already and with  a variant normally made, and to alter laziness AD>??? The Same simply question of compilation, instead of the code. I already wrote a stub, which, I hope, quite safe for longjump And to recompile in a C ++ is or to set "force a C ++" for *.c, or to turn in *.cpp. Both that and another - demands , and to set options for separate files - generally to me categorically it is not pleasant

10

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: M> And to recompile in a C ++ is or to set "force a C ++" for *.c, or to turn in *.cpp. Both that and another - demands , and to set options for separate files - generally to me categorically it is not pleasant And you LUA not as static  ? On-occasion longjump -  you will run on , it will be insulting that because of own laziness.

11

Re: Reset of errors in Lua, how?

Hello, IID, you wrote: M>> And to recompile in a C ++ is or to set "force a C ++" for *.c, or to turn in *.cpp. Both that and another - demands , and to set options for separate files - generally to me categorically it is not pleasant IID> And you LUA not as static  ? Yes is not present, it is simple in the project added  Lua IID> on-occasion longjump -  you will run on , it will be insulting that because of own laziness. Well, I turn each call in function without any . All the same from it I cause class methods. At the same time catching of an exception and the negative return code I process as an error

12

Re: Reset of errors in Lua, how?

Hello, Marty, you wrote: IID>> And you LUA not as static  ? M> Yes is not present, it is simple in the project added  Lua Well and in vain. IID>> on-occasion longjump -  you will run on , it will be insulting that because of own laziness. M> well, I turn each call in function without any . All the same from it I cause class methods. At the same time catching of an exception and the negative return code I process as an error It . Because the error can jump out in , inside LUA engine, at any   the data. All RAII flies to devils . And to go into the sun manually not my method.