lua-users home
lua-l archive

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




On 2018-02-01 06:34 PM, Tim Hill wrote:

On Feb 1, 2018, at 8:41 AM, Sean Conner <sean@conman.org> wrote:

It was thus said that the Great Dibyendu Majumdar once stated:
Hi

Sorry I should know the answer to this but I don't. Does Lua support dotted module names... i.e. map to directory path?
  You mean something like:

	net = require "org.conman.net" --?

If so, then yes, Lua does.

  -spc


This cleanly solves the external namespace, assuming someone can promote some form of standardization around whatever convention is agreed (LuaRocks team???). But it leaves open that global variable used for the assignment target. If I control the whole corpus of Lua code in a project, then I can control the internal global namespace, but if I’m using 3rd party Lua code which ITSELF using require(), how to I handle namespace collisions on these globals?

This would seem to recommend a coding style where a loadable Lua module use locals only for require():

local net = require(“org.timhill.network”)
…

—Tim



I don't like using centralized authorities (DNS) for this stuff.

Why not use UUIDs?

local net = require "YOUR_UUID.network"

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.