This topic contains 1 reply, has 2 voices, and was last updated by  Jeff Drumm 6 years ago.

A question about scope within and across channels

  • I need some clarification, please, around the scope of Lua variables.
    I’ve observed that global variables maintain state across channel invocations.

    Are these variables only within the scope of the channel they are declared within?
    Is it possible for any variable to be visible and maintain state across running channels?


    Each translator executes its own interpreter; global variables are not visible across multiple channels (or even multiple translators within the same channel).

    If you need to communicate state information between translator instances, you’ll need to either encapsulate it in some sort of message envelope that can be decomposed by downstream translators, or use an external mechanism such as a database table (with the concomitant concerns re: concurrent access, locking, race conditions, etc.).

    Jeff Drumm ◊ VP and COO ◊ HICG, LLC. ◊

You must be logged in to reply to this topic.