[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luac & 5.2?
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Fri, 30 Mar 2012 15:35:25 -0700
On Friday 30, Petite Abeille wrote:
> On Mar 30, 2012, at 11:22 PM, Petite Abeille wrote:
> > In 5.2, the same process doesn't seem to work any longer.
>
> Another luac & 5.2 weirdness.
>
> Assuming the following setup:
>
>
> $ cat TestA.lua
> local print = print
> local _NAME = ...
> local _ENV = {}
>
> print( 'TestA', _NAME )
>
> return _ENV
>
>
> $ cat TestB.lua
> local print = print
> local _NAME = ...
> local _ENV = {}
>
> print( 'TestB', _NAME )
>
> return _ENV
>
>
> $ cat TestC.lua
> local TestA = require( 'TestA' )
> local TestB = require( 'TestB' )
>
> print( 'TestC' )
>
>
> $ lua TestC.lua
> TestA TestA
> TestB TestB
> TestC
>
>
> All good. Each module gets loaded once.
>
>
> Now… same, but with luac:
>
>
> $ luac -o TestC.luac TestA.lua TestB.lua TestC.lua
>
> $ 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.
>
> Bug or feature?
>
> What gives?
The modules are not registering them selves in the package.loaded table (this
is one of the things module() does), so require() loads the modules again from
the original Test*.lua files.
--
Robert G. Jakabosky