lua-users home
lua-l archive

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


On Apr 2, 2012, at 8:32 AM, steve donovan wrote:

> As for moving beyond module(), I can totally recommend Egil's global.lua tool:
> 
> http://lua-users.org/lists/lua-l/2012-03/msg00890.html

Nice. But sadly this doesn't seem to handle _ENV properly. Or perhaps I don't understand what it does :)


For example:

$ ./globals.lua IMAP.lua

IMAP.lua
 !!! _NAME        : 583

Which refers to this line:

function meta:__tostring()
    return ( '%s/%s' ):format( _NAME, _VERSION )
end

http://dev.alt.textdrive.com/browser/Mail/IMAP.lua#L583


_NAME is set for the current environment, on line 39:

local _ENV = module( 'IMAP' )

http://dev.alt.textdrive.com/browser/Mail/IMAP.lua#L39


The environment _NAME itself is set here in the, hmmm, 'module' module:

http://dev.alt.textdrive.com/browser/Mail/module.lua#L39

Why is it flagged as a global access?  Did I misunderstood something?


Another example:

$ ./globals.lua IMAPFetch.lua

IMAPFetch.lua
 !!! FetchRanges  : 754
 !!! _NAME        : 765

This time, aside from _NAME, it also flags FetchRanges, which is defined on line 47:

http://dev.alt.textdrive.com/browser/Mail/IMAPFetch.lua#L47

And then accessed on line 754:

http://dev.alt.textdrive.com/browser/Mail/IMAPFetch.lua#L754


As this function has been defined in its own _ENV, it's not a global as far as I can tell.

What gives?