lua-users home
lua-l archive

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


On 21 July 2010 21:45, HyperHacker <hyperhacker@gmail.com> wrote:
>
> I think a lot of the suggestions made so far are basically syntactic
> sugar for this. If you're using a lot of functions from the global
> namespace it'd be somewhat annoying to have to do "local print, io,
> string, table = G.print, G.io, G.string, G.table" etc all the time.
>
> Perhaps a solution here is a "_module" table, which works similar to
> _G, containing all modules that have been loaded to the global
> namespace. i.e. at startup it would contain {string, os, io} etc as
> well as perhaps some of the built-in globals like print, package, and
> pcall (or perhaps these should be in modules of some sort as well).
>

$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "socket"
> for k,v in pairs(package.loaded) do print(k,v) end
string	table: 0x9a5d618
debug	table: 0x9a60970
package	table: 0x9a5da50
_G	table: 0x9a5c450
io	table: 0x9a5eba0
os	table: 0x9a5f3a8
table	table: 0x9a5d100
math	table: 0x9a5ff70
socket.core	table: 0x9a73110
coroutine	table: 0x9a5d718
socket	table: 0x9a73110

Not sure how this helps most cases discussed so far though :)

Matthew