lua-users home
lua-l archive

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

(Hopefully it sends correctly this time)

We currently have raw requires, which means we do things like

local a = require"io.github.soniex2.a"
local b = require"io.github.soniex2.b"
local c = require"io.github.soniex2.b.c"
-- use a, b and c normally

Instead of that, is there a module or something that lets me do something like

local soniex2 = reqpath"io.github.soniex2"
local a = soniex2("a") -- alternatively, `soniex2.a()`
local b = soniex2("b") -- alternatively, `soniex2.b()`
local c = soniex2("b.c") -- alternatively, `soniex2.b.c()`, with the call at the -- end for disambiguating between module and path, and -- setting an __index is not an option as the module
                         -- could already have its own __index (or not be a
                         -- table at all; some modules return functions!).
-- use a, b and c normally

I think it looks nicer.

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.