Lua-API++  2015-02-12-3
Lua-API++ library
Retval Class Referencefinal

Return value for Lua functions. More...

Inherits returnableByAny, and noNew.

Detailed Description

Return value for Lua functions.

This type is used for returning values from functions. You cannot create Retval directly, only by using Context::ret or Context::error functions. You can, however, delegate its creation to another function like this:

Retval delegated(int rv, Context& context){ // Note that this function does not conform to LFunction specification
return context.ret(rv);
}
Retval myFunction(Context& context){ // This is a proper LFunction
return delegated(42, context); // Returns externally created Retval
}
Warning
After Retval is created, automatic stack management is shut down, so no other stack-involving actions must be taken after that happens. The best way to guarantee that is to use any Retval-creating expressions only with return operator.