lua-users home
lua-l archive

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


it's what I found through googling:
http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/old/luasocket-2.0-beta/home.html#download

Where do I get a more recent version?
thanks!
wes

On Wed, Apr 29, 2009 at 3:55 PM, Diego Nehab <diego@tecgraf.puc-rio.br> wrote:
> Hi,
>
>> Why in lua socket is there a totally different way to require modules
>> than the usual require("ftp")?  I've just downloaded the 2.0 beta and
>> it has this following chunk:
>>
>> -- finds a lua library and returns the entrypoint
>> local function find(lib)
>>   local path = LUA_PATH or os.getenv("LUA_PATH") or "?;?.lua"
>>   local f, e1
>>   for p in string.gfind(path, "[^;]+") do
>>     local n = string.gsub(p, "%?", lib)
>>     f, e1 = loadfile(n)
>>     if f then break end
>>   end
>>   return f, e1
>> end
>>
>> -- new "require" function
>> function require(name)
>>   if not _LOADED[name] then
>>       local f = assert(find(name))
>>       local m = {}
>>       setmetatable(m, {__index = _G})
>>       setfenv(f, m)
>>       f()
>>       _LOADED[name] = m
>>   end
>>   return _LOADED[name]
>> end
>>
>>
>> that has to be executed to properly "require" something like ftp.  Is
>> there a reason for this?  It seems overly complex when a simple
>> module("ftp") would suffice inside the ftp.lua script.
>
> Back in the old 2.0 beta days, Lua didn't have a good package
> system... Why are you using 2.0 beta anyway?
>
> Regards,
> Diego
>