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 Peter Aronoff once stated:
> Paige DePol <lual@serfnet.org> wrote:
> > Soni They/Them L. <fakedme@gmail.com> wrote:
> > 
> > > I don't like using centralized authorities (DNS) for this stuff.
> > > 
> > > Why not use UUIDs?
> > > 
> > > local net = require "YOUR_UUID.network"
> > 
> > UUID Identifier:
> > 
> > local mod = require "5ae29a42-0795-11e8-ba89-0ed5f89f718b"
> > 
> > Versus:
> > 
> > local mod = require "net.fizzypop.socket"
> 
> In fairness to Soni, shouldn’t that be
> 
> local mod = require "5ae29a42-0795-11e8-ba89-0ed5f89f718b.socket"
> 
> > For example, it is way more apparent what "net.fizzypop.socket" will
> > do... without having to look it up somewhere how would you know what
> > "5ae29a42-0795-11e8-ba89-0ed5f89f718b" does?
> 
> See above: this is a draw: the socket part gives equal information in both.
> 
> That said, I also prefer the domain-style.

  I do too, but the last time (I remember) namespacing was brought up [1]
the domain-style namespaces weren't popular [2].  But to go through with the
UUID idea, here's a portion of code I wrote, modified to use UUID
namespacing:

local syslog   = require "6CC24CA3-0D40-550D-9B0F-EF54C94C54C1.syslog"
local fsys     = require "6CC24CA3-0D40-550D-9B0F-EF54C94C54C1.fsys"
local tty      = require "13DC8997-46AB-54E2-9BC4-10C88CFAC5D4.tty"
local xdg      = require "13DC8997-46AB-54E2-9BC4-10C88CFAC5D4.xdg"
local viewfunc = require "13DC8997-46AB-54E2-9BC4-10C88CFAC5D4.luaview.viewfunc"
local viewtab  = require "13DC8997-46AB-54E2-9BC4-10C88CFAC5D4.luaview.viewtab"
local debug    = require "B72AF792-1509-54D6-9B46-1EE59547AA2B.debug"
local table    = require "B72AF792-1509-54D6-9B46-1EE59547AA2B.table"
local string   = require "B72AF792-1509-54D6-9B46-1EE59547AA2B.string"
local os       = require "B72AF792-1509-54D6-9B46-1EE59547AA2B.os"

  Those last four are the stock Lua modules "debug", "table", "string" and
"os" (I mean, why not go all the way?).  It's pretty ugly (in my opinion)
but there's a deeper problem---C modules.  You can't name them in this form
at all.  So I created a subdirectory "6CC24CA3-0D40-550D-9B0F-EF54C94C54C1"
and in there, I have "syslog.so".  In the C file, I had to name the main
function

	int luaopen_6CC24CA3_0D40_550D_9B0F_EF54C94C54C1_syslog(lua_State *L)
	{ ... }

because the '-' isn't a valid in a C identifier.  But when I tried:

	local syslog = require "6CC24CA3-0D40-550D-9B0F-EF54C94C54C1.syslog"

I get:

lua-53: error loading module '6CC24CA3-0D40-550D-9B0F-EF54C94C54C1.syslog' from file './6CC24CA3-0D40-550D-9B0F-EF54C94C54C1/syslog.so':
        ./6CC24CA3-0D40-550D-9B0F-EF54C94C54C1/syslog.so: undefined symbol: luaopen_0D40-550D-9B0F-EF54C94C54C1_syslog

Replacing the '-' with '_' (renaming the directory and fixing the call to
require()) does, however, work.  So the above should be written:

local syslog   = require "6CC24CA3_0D40_550D_9B0F_EF54C94C54C1.syslog"
local fsys     = require "6CC24CA3_0D40_550D_9B0F_EF54C94C54C1.fsys"
local tty      = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.tty"
local xdg      = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.xdg"
local viewfunc = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.luaview.viewfunc"
local viewtab  = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.luaview.viewtab"
local debug    = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.debug"
local table    = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.table"
local string   = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.string"
local os       = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.os"

  Another issue---it's pretty easy to see what modules come from what
"organization" but if you mix things up a bit:

local debug    = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.debug"
local fsys     = require "6CC24CA3_0D40_550D_9B0F_EF54C94C54C1.fsys"
local os       = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.os"
local string   = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.string"
local syslog   = require "6CC24CA3_0D40_550D_9B0F_EF54C94C54C1.syslog"
local table    = require "B72AF792_1509_54D6_9B46_1EE59547AA2B.table"
local tty      = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.tty"
local viewfunc = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.luaview.viewfunc"
local viewtab  = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.luaview.viewtab"
local xdg      = require "13DC8997_46AB_54E2_9BC4_10C88CFAC5D4.xdg"

the UUIDs tend to bleed together.

  -spc (And everybody knows that 2D69069E_DCE0_4FCA_9039_FA8D36ED3D8D.socket
	is more widely used than 242BAD83_B72D_4989_81B1_4873107FF68B.socket
	... or was it 2d69069e_dce0_4fca_9039_fa8d36ed3d8d.socket?)

[1]	http://lua-users.org/lists/lua-l/2013-11/msg00684.html

[2]	Thread starting here:
	http://lua-users.org/lists/lua-l/2013-11/msg00727.html [3]

[3]	Where I proposed using UUIDs as a prefix as part of a joke.