lua-users home
lua-l archive

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


On Fri, Mar 30, 2012 at 6:29 PM, Petite Abeille
<petite.abeille@gmail.com> wrote:
> $ lua TestC.luac
> TestA   nil
> TestB   nil
> TestA   TestA
> TestB   TestB
> TestC
>
> Note how the modules have been invoked twice, once with a null argument, and once with their file name.

This is clearly caused by the "main" function generated by luac
running each source file successively. Finally, the two require lines
in TestC.lua loading each Test[AB].lua file again and running them.

I don't have time to check but I suspect luac is generating a main
function that looks like this:

do
  <TestA.lua>
end
do
  <TestB.lua>
end
do
  <TestC.lua>
end

When using the (deprecated) module function, it changes the _ENV of
this main function and so sabotages all source files later on.

-- 
- Patrick Donnelly