lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 22 October 2013 17:37, Robert Virding <robert.virding@erlang-solutions.com> wrote:
It would also be interesting to speculate how to handle multiple versions of a module in the same system. In one sense it would be easy if they were kept in different places but overwriting an existing one may be tricky.

Are you wanting to map Erlang module semantics onto Lua? If so I think it's doable :-)

Load the module N times, each time assigning the global name to the latest version (e.g. using Justin's trick).

Inside the module, make all functions 'local', so that intra-module calls between them will early-bind to this module version.

Implement '-export()' by putting functions into a dictionary (e.g. returned at bottom of file as module result).

Make remote calls like 'module.foo()'. These will late-bind on the latest value for 'module'.

not sure how to go about purging version 1..n-2 as Erlang does.