lua-users home
lua-l archive

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

It was thus said that the Great Josh Simmons once stated:
> On Tue, Oct 18, 2011 at 6:20 PM, Sean Conner <> wrote:
> >
> >  "But module() and require() could keep a private table with references to
> > each module and not dump them into the global space," you say.  Okay, but
> > you *still* need a global namespace, because DarkGod has *his* DNS module
> > (named dns) and I have *my* DNS module (which would also be named "dns"), so
> > which one is returned when you require("dns")?  (assuming that I have
> > modules I wrote using my DNS module, and some other modules I want to use
> > might be using DarkGod's DNS module)
> >
> Require already does this, and you need to separate them at the
> filesystem level irregardless of what scope they're imported into.
> local dns = require 'crazy.weird.dns'
> local dns2 = require 'somebody.elses.dns'
> None of this has anything to do with global scope or module.

  My Lua paths have several locations where modules can lurk:





(that last path in each is for work related Lua stuff)

  And just doing a 

	require "dns"

will grab the first file matching dns.lua or, and woe to code that
expects CrazyWeird DNS module (living under /usr/local/lib/lua/5.1/
and gets SomebyElse's DNS module (living under

  -spc (So yeah, the filesystem does this to a degree, but you can still
	get messed up ... )