lua-users home
lua-l archive

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




On 2018-02-01 08:55 PM, Sean Conner wrote:
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"

local MOD_LUA = "B72AF792-1509-54D6-9B46-1EE59547AA2B"
local MOD_SC = "6CC24CA3-0D40-550D-9B0F-EF54C94C54C1"
local MOD_IDK = "13DC8997-46AB-54E2-9BC4-10C88CFAC5D4"

local syslog   = require (MOD_SC .. ".syslog")
local fsys     = require (MOD_SC .. ".fsys")
local tty      = require (MOD_IDK .. ".tty")
local xdg      = require (MOD_IDK .. ".xdg")
local viewfunc = require (MOD_IDK .. ".luaview.viewfunc")
local viewtab  = require (MOD_IDK .. ".luaview.viewtab")
local debug    = require (MOD_LUA .. ".debug")
local table    = require (MOD_LUA .. ".table")
local string   = require (MOD_LUA .. ".string")
local os       = require (MOD_LUA .. ".os")

(But we'd probably end up with something more interesting...

local MOD_LUA = mod "B72AF792-1509-54D6-9B46-1EE59547AA2B"

local debug = MOD_LUA.require "debug"
-- etc

)


   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

Huh. This is odd to me.

What I'd expect is:

require "a.c.mod" -->

search "a.so", find "luaopen_c_mod" in it.
search "a/c.so", find "luaopen_mod" in it.
search "a/c/mod.so", find "luaopen" in it.

I guess Lua treats this C/dynamic linking stuff quite weirdly. Oh well.

(Also all of them should receive the same thing as standard Lua modules: the full mod name and path, IMO. Idk I feel like there's absolutely no reason for hardcoding. I don't hardcode my Lua modules either, I always use "relative require" with `...`.)

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.


--
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.