Hello!
On Tue, May 27, 2014 at 11:41 AM, arthurx wrote:
> I am experimenting in modularizing some of my codes and have a problem about
> variable scope. Lets say in the main lua scripts there are a bunch of local
> variables like
> local name = "John"
> local messages = {...}
>
> And in the module there are many functions that are depending on these
> variables. For an extreme example suppose there is a function do_update()
> they would depend on all those variables in the main script.
>
It seems that you can just follow the Object Oriented (OO) paradigm
here by encapsulating all your data fields in an "object" :) So that
you can pass your "object" as a whole to each of your functions (or
"methods" in OO's terms).
See lua-resty-redis and lua-resty-lock for such OO examples in the real world :)
Best regards,
-agentzh