UNDEF

Introduction

Lua does not natively have the concept of “undefined” elements of an table. Setting the value of a Lua table or list object to nil means that the element is “not present”.

However, several of the n2svcd framework methods require an explicit distinction between “present but not specified” and “not present”. This applies to the INAP and TCAP Agents, as well as many other Agents.

The global constant UNDEF is provided specifically for interacting with the n2svcd framework in these cases, to specify “this table value is present but undefined”.

When a Lua script running in LogicApp wishes to send “undefined” to a framework method (rather than nil), it can specify the UNDEF global constant:

    n2svcd.debug_var ({ 'X', UNDEF, 'Y' })

When receiving variables back from the framework, Lua scripts may need to be aware that the UNDEF global constant may be returned as an table value or as a value in a list.

The UNDEF global constant is a “lightweight user-data” variable in Lua.

Service logic can easily test if a returned value is UNDEF with the equality operator, e.g.

    if (result.subvalue == UNDEF) then
        result.subvalue = nil
    end

Note that the UNDEF global constant is injected into the Lua environment by the LogicApp, it is not necessary to include any particular “require” file in order to acquire it.