[proposal] require resources

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[proposal] require resources

Soni "They/Them" L.
currently we can require code. but it'd be nice to be able to require
resources, using (mostly) the same module machinery.
'
require("foo.bar", "res.txt") would look for "res.txt" as a file in
module "foo.bar", regardless of what 'module "foo.bar"' is - except that
it must be a module.

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Egor Skriptunoff-2
On Mon, Jan 20, 2020 at 3:25 AM Soni "They/Them" L. wrote:
require("foo.bar", "res.txt") would look for "res.txt" as a file in
module "foo.bar"

What value is expected to be returned by require("foo.bar", "res.txt")?

Why not using a function for the same task?
local res = require("foo.bar").get_resource()

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Soni "They/Them" L.
If you had:

LUA_PATH/foo/init.lua
LUA_PATH/foo/bar/init.lua
LUA_PATH/foo/bar/res.txt

then require("foo.bar", "res.txt") would get you the contents of
LUA_PATH/foo/bar/res.txt

HOWEVER this would only apply to the default loaders. what I mean by
that is that one could make a zip file loader and then you can have your
whole module (and submodules) as a zip file instead.

foo.zip
| init.lua
| bar/init.lua
| bar/res.txt

which is a lot harder than opening a file in LUA_PATH.

On 2020-01-19 9:37 p.m., Egor Skriptunoff wrote:

> On Mon, Jan 20, 2020 at 3:25 AM Soni "They/Them" L. wrote:
>
>     require("foo.bar", "res.txt") would look for "res.txt" as a file in
>     module "foo.bar"
>
>
> What value is expected to be returned by require("foo.bar", "res.txt")?
>
> Why not using a function for the same task?
> local res = require("foo.bar").get_resource()
>


Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Egor Skriptunoff-2
On Mon, Jan 20, 2020 at 4:26 AM Soni "They/Them" L. wrote:
If you had:

LUA_PATH/foo/init.lua
LUA_PATH/foo/bar/init.lua
LUA_PATH/foo/bar/res.txt

then require("foo.bar", "res.txt") would get you the contents of
LUA_PATH/foo/bar/res.txt



Should require() cache resources the same way as modules?

Would it be possible to have a module containing only resources without any code?

Could main program have its own resources (files from the same directory)?
require(nil, "res.txt")

Resources might be large enough, so it would be better to return a pseudo-file object
instead of huge Lua string.
local res = open_resource("foo.bar", "res.txt")
local data = res:read("*a")
res:close()
Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Soni "They/Them" L.


On 2020-01-19 11:20 p.m., Egor Skriptunoff wrote:

> On Mon, Jan 20, 2020 at 4:26 AM Soni "They/Them" L. wrote:
>
>     If you had:
>
>     LUA_PATH/foo/init.lua
>     LUA_PATH/foo/bar/init.lua
>     LUA_PATH/foo/bar/res.txt
>
>     then require("foo.bar", "res.txt") would get you the contents of
>     LUA_PATH/foo/bar/res.txt
>
>
>
> Should require() cache resources the same way as modules?

not quite the same: yes, but with __mode="v"

>
> Would it be possible to have a module containing only resources
> without any code?

yes

>
> Could main program have its own resources (files from the same directory)?
> require(nil, "res.txt")

evil, but maybe? why not just put them in a submodule?

>
> Resources might be large enough, so it would be better to return a
> pseudo-file object
> instead of huge Lua string.
> local res = open_resource("foo.bar", "res.txt")
> local data = res:read("*a")
> res:close()

tell me, when was the last time you didn't need to keep your app's icons
loaded once you loaded them for the first time? in any case __mode="v"
should help with this.

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
In reply to this post by Soni "They/Them" L.
It was thus said that the Great Soni They/Them L. once stated:
> If you had:
>
> LUA_PATH/foo/init.lua
> LUA_PATH/foo/bar/init.lua
> LUA_PATH/foo/bar/res.txt
>
> then require("foo.bar", "res.txt") would get you the contents of
> LUA_PATH/foo/bar/res.txt

  Here's my current package.path, broken down to it's easy to see the
contents:

        /home/spc/.luarocks/share/lua/5.3/?.lua
        /home/spc/.luarocks/share/lua/5.3/?/init.lua
        /home/spc/.luarocks/lib/lua/5.3/?.lua
        /home/spc/.luarocks/lib/lua/5.3/?/init.lua
        /usr/local/share/lua/5.3/?.lua
        /usr/local/share/lua/5.3/?/init.lua
        /usr/local/lib/lua/5.3/?.lua
        /usr/local/lib/lua/5.3/?/init.lua
        ./?.lua
        ./?/init.lua

  And to make things even worse, let's say I have an app:

        org.conman.app.gopherclient

  As currently defined, when I do

        app = require "org.conman.app.gopherclient"

Lua will check for the following:

/home/spc/.luarocks/share/lua/5.3/org/conman/app/gopherclient.lua
/home/spc/.luarocks/share/lua/5.3/org/conman/app/gopherclient/init.lua
/home/spc/.luarocks/lib/lua/5.3/org/conman/app/gopherclient.lua
/home/spc/.luarocks/lib/lua/5.3/org/conman/app/gopherclient/init.lua
/usr/local/share/lua/5.3/org/conman/app/gopherclient.lua
/usr/local/share/lua/5.3/org/conman/app/gopherclient/init.lua
/usr/local/lib/lua/5.3/org/conman/app/gopherclient.lua
/usr/local/lib/lua/5.3/org/conman/app/gopherclient/init.lua
./org/conman/app/gopherclient.lua
./org/conman/app/gopherclient/init.lua

  Right now, Lua goes through the package.searchers array, calling each
function in turn.  The second searcher will break the value in package.path
by the template splitting character (default of ';'---not shown in the list
above) and replace any dots in the module name with the systems directory
separator ('\' in Windows, '/' in non-Windows, but it could technically be
anything).  Then for each template in package.path, it substitues the
substitution point (defaults to '?') with the modified module name.

  I don't think this is anything you don't know, but look at what is
*actually* happening here---Lua is constructing special values it gives to
fopen() (the C function responsible for opening a file)---Lua itself has no
concept of "directories".  It doesn't have the concept of extensions
(otherwise, why include them in the template?).  It just constructs special
opaque (to Lua) values and hands them off to fopen().  That's it.

  How would you fit "gopher.icon" into this?  Remember, there is no concept
of a directory or even extensions in Lua.  It's all must magic opaque values
as far as Lua is concerned.  Given the line:

        gc,icon = require("org.conman.app.gopherclient","gopher.icon")

where would "gopher.icon" even live?  At the same level as
org.conman.app.gopherclient.lua?  What if gopherclient was in fact a
directory?  Or both org/conman/app/gopherclient.lua and
org/conman/app/gopherclient/? (both a file *and* a directory?) I do that
quite often for my own modules and it works fine.

  And is it just one resource?  What if there are more?  Like a database of
text translations for different langauges?  Multiple icons for different
windows?  Sounds?

  It might seem like a simple request, but it's not.

> HOWEVER this would only apply to the default loaders. what I mean by
> that is that one could make a zip file loader and then you can have your
> whole module (and submodules) as a zip file instead.
>
> foo.zip
> | init.lua
> | bar/init.lua
> | bar/res.txt
>
> which is a lot harder than opening a file in LUA_PATH.

  Not really.  Back in 2014 I did some experiments with doing just this (for
Lua 5.1) [1].  I got to the point where I could run LuaRocks entirely out of
a ZIP file.  I even patched loadfile() and dofile() to handle opening of
files in the ZIP, but they only supported read-only files.  I could not get
Lua modules written in C working, but that's due to a limitation of loading
dynamic objects (only from disk, not from memory [2]).

  All it requried (for Lua modules in Lua) was adding a new entry into the
package.searchers array.  And why would a require() with resources just be
limited to the included searchers?  

  -spc

[1] Some of which can be viewed here:

                https://github.com/spc476/LEM

[2] Don't ask me why not, ask the guys who wrote the OS why the
        limitation.  I'm not reponsible for that one.

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
In reply to this post by Soni "They/Them" L.
It was thus said that the Great Soni They/Them L. once stated:
>
> tell me, when was the last time you didn't need to keep your app's icons
> loaded once you loaded them for the first time? in any case __mode="v"
> should help with this.

  Just last week.  The GUI I use creates the icon from the resource source
material at runtime (it has to as that's how it operations---ask the guys
who wrote the GUI, not me), and once that's happens, the resource source
material doesn't need to remain open.

  -spc (Theer are always exceptions ... )

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Soni "They/Them" L.
In reply to this post by Sean Conner


On 2020-01-20 1:10 a.m., Sean Conner wrote:

> It was thus said that the Great Soni They/Them L. once stated:
> > If you had:
> >
> > LUA_PATH/foo/init.lua
> > LUA_PATH/foo/bar/init.lua
> > LUA_PATH/foo/bar/res.txt
> >
> > then require("foo.bar", "res.txt") would get you the contents of
> > LUA_PATH/foo/bar/res.txt
>
>    Here's my current package.path, broken down to it's easy to see the
> contents:
>
> /home/spc/.luarocks/share/lua/5.3/?.lua
> /home/spc/.luarocks/share/lua/5.3/?/init.lua
> /home/spc/.luarocks/lib/lua/5.3/?.lua
> /home/spc/.luarocks/lib/lua/5.3/?/init.lua
> /usr/local/share/lua/5.3/?.lua
> /usr/local/share/lua/5.3/?/init.lua
> /usr/local/lib/lua/5.3/?.lua
> /usr/local/lib/lua/5.3/?/init.lua
> ./?.lua
> ./?/init.lua
>
>    And to make things even worse, let's say I have an app:
>
> org.conman.app.gopherclient
>
>    As currently defined, when I do
>
> app = require "org.conman.app.gopherclient"
>
> Lua will check for the following:
>
> /home/spc/.luarocks/share/lua/5.3/org/conman/app/gopherclient.lua
> /home/spc/.luarocks/share/lua/5.3/org/conman/app/gopherclient/init.lua
> /home/spc/.luarocks/lib/lua/5.3/org/conman/app/gopherclient.lua
> /home/spc/.luarocks/lib/lua/5.3/org/conman/app/gopherclient/init.lua
> /usr/local/share/lua/5.3/org/conman/app/gopherclient.lua
> /usr/local/share/lua/5.3/org/conman/app/gopherclient/init.lua
> /usr/local/lib/lua/5.3/org/conman/app/gopherclient.lua
> /usr/local/lib/lua/5.3/org/conman/app/gopherclient/init.lua
> ./org/conman/app/gopherclient.lua
> ./org/conman/app/gopherclient/init.lua
>
>    Right now, Lua goes through the package.searchers array, calling each
> function in turn.  The second searcher will break the value in package.path
> by the template splitting character (default of ';'---not shown in the list
> above) and replace any dots in the module name with the systems directory
> separator ('\' in Windows, '/' in non-Windows, but it could technically be
> anything).  Then for each template in package.path, it substitues the
> substitution point (defaults to '?') with the modified module name.
>
>    I don't think this is anything you don't know, but look at what is
> *actually* happening here---Lua is constructing special values it gives to
> fopen() (the C function responsible for opening a file)---Lua itself has no
> concept of "directories".  It doesn't have the concept of extensions
> (otherwise, why include them in the template?).  It just constructs special
> opaque (to Lua) values and hands them off to fopen().  That's it.
>
>    How would you fit "gopher.icon" into this?  Remember, there is no concept
> of a directory or even extensions in Lua.  It's all must magic opaque values
> as far as Lua is concerned.  Given the line:
>
> gc,icon = require("org.conman.app.gopherclient","gopher.icon")
>
> where would "gopher.icon" even live?  At the same level as
> org.conman.app.gopherclient.lua?  What if gopherclient was in fact a
> directory?  Or both org/conman/app/gopherclient.lua and
> org/conman/app/gopherclient/? (both a file *and* a directory?) I do that
> quite often for my own modules and it works fine.
>
>    And is it just one resource?  What if there are more?  Like a database of
> text translations for different langauges?  Multiple icons for different
> windows?  Sounds?
>
>    It might seem like a simple request, but it's not.

The same can be said of require.

Again it would just be replacing patterns:

icon = require("org.conman.app.gopherclient","gopher.icon")

replace the left's .'s with /'s, add / at the end, add right at the end.

if you had resource path /usr/lib/lua/5.4/? for example, it would try to
open /usr/lib/lua/5.4/org/conman/app/gopherclient/gopher.icon

>
> > HOWEVER this would only apply to the default loaders. what I mean by
> > that is that one could make a zip file loader and then you can have your
> > whole module (and submodules) as a zip file instead.
> >
> > foo.zip
> > | init.lua
> > | bar/init.lua
> > | bar/res.txt
> >
> > which is a lot harder than opening a file in LUA_PATH.
>
>    Not really.  Back in 2014 I did some experiments with doing just this (for
> Lua 5.1) [1].  I got to the point where I could run LuaRocks entirely out of
> a ZIP file.  I even patched loadfile() and dofile() to handle opening of
> files in the ZIP, but they only supported read-only files.  I could not get
> Lua modules written in C working, but that's due to a limitation of loading
> dynamic objects (only from disk, not from memory [2]).
>
>    All it requried (for Lua modules in Lua) was adding a new entry into the
> package.searchers array.  And why would a require() with resources just be
> limited to the included searchers?

It wouldn't. Add a resource searcher/loader.

>
>    -spc
>
> [1] Some of which can be viewed here:
>
> https://github.com/spc476/LEM
>
> [2] Don't ask me why not, ask the guys who wrote the OS why the
> limitation.  I'm not reponsible for that one.

Write your own dynamic loader/linker ;)

>


Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
It was thus said that the Great Soni They/Them L. once stated:

> > On 2020-01-20 1:10 a.m., Sean Conner wrote:
> >   It might seem like a simple request, but it's not.
>
> The same can be said of require.
>
> Again it would just be replacing patterns:
>
> icon = require("org.conman.app.gopherclient","gopher.icon")
>
> replace the left's .'s with /'s, add / at the end, add right at the end.
>
> if you had resource path /usr/lib/lua/5.4/? for example, it would try to
> open /usr/lib/lua/5.4/org/conman/app/gopherclient/gopher.icon

  Does it ever occur to you to actually *try* to implement your ideas?  

  This idea, with a separate resource path, could be done in pure Lua.  Add
a package.rpath (for resource path), then replace require() to look for two
parameters and handle it appropriately?  I know I made a similar change
(adding a path, adding a new searcher function) to load C functions directly
from source [1].  And then hey, post the code and get feedback.

  -spc (Sigh)

[1] https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.lua

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Griffin Rock
From: [hidden email] <[hidden email]> on behalf of Sean Conner <[hidden email]>
> Does it ever occur to you to actually *try* to implement your ideas? 
> This idea, with a separate resource path, could be done in pure Lua.
> Add a package.rpath (for resource path), then replace require() to look for two
> parameters and handle it appropriately?

how about this:

---------- resource.lua
if not package.rpath then
        local path = {}
        for file in package.path:gmatch "[^;]*?" do
                if not path[file] then
                        path[file] = 1
                        table.insert(path,file);
                end
        end
        package.rpath = table.concat(path, ";")
end
local function resource (fname)
        local r = package.searchpath(fname, package.rpath, ":")
        if r then
                return function()
                        local f = io.open(r)
                        local t = f:read "*a"
                        f:close()
                        return t
                end
        end
end
table.insert(package.searchers, 2, resource)
return resource
----------

example of use:
require "resource"
icon = require "package:gopher.icon"
Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
It was thus said that the Great Griffin Rock once stated:

> From: [hidden email] <[hidden email]> on behalf of Sean Conner <[hidden email]>
> > Does it ever occur to you to actually *try* to implement your ideas? 
> > This idea, with a separate resource path, could be done in pure Lua.
> > Add a package.rpath (for resource path), then replace require() to look for two
> > parameters and handle it appropriately?
>
> how about this:
>
> ---------- resource.lua
> if not package.rpath then
> local path = {}
> for file in package.path:gmatch "[^;]*?" do
> if not path[file] then
> path[file] = 1
> table.insert(path,file);
> end
> end
> package.rpath = table.concat(path, ";")
> end
> local function resource (fname)
> local r = package.searchpath(fname, package.rpath, ":")
> if r then
> return function()
> local f = io.open(r)
> local t = f:read "*a"
> f:close()
> return t
> end
> end
> end
> table.insert(package.searchers, 2, resource)
> return resource
> ----------
>
> example of use:
> require "resource"
> icon = require "package:gopher.icon"

  This doesn't work because package.searchpath() isn't exactly what you want
(read it closely).  When I tried this:

lua: t.lua:2: module 'package:gopher.icon' not found:
        no field package.preload['package:gopher.icon']
        no file '/home/spc/.luarocks/share/lua/5.3/package:gopher/icon.lua'
        no file '/home/spc/.luarocks/share/lua/5.3/package:gopher/icon/init.lua'
        no file '/home/spc/.luarocks/lib/lua/5.3/package:gopher/icon.lua'
        no file '/home/spc/.luarocks/lib/lua/5.3/package:gopher/icon/init.lua'
        no file '/usr/local/share/lua/5.3/package:gopher/icon.lua'
        no file '/usr/local/share/lua/5.3/package:gopher/icon/init.lua'
        no file '/usr/local/lib/lua/5.3/package:gopher/icon.lua'
        no file '/usr/local/lib/lua/5.3/package:gopher/icon/init.lua'
        no file './package:gopher/icon.lua'
        no file './package:gopher/icon/init.lua'
        no file '/home/spc/.luarocks/lib/lua/5.3/package:gopher/icon.so'
        no file '/usr/local/lib/lua/5.3/package:gopher/icon.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './package:gopher/icon.so'
        no file '/home/spc/.luarocks/lib/lua/5.3/package:gopher.so'
        no file '/usr/local/lib/lua/5.3/package:gopher.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './package:gopher.so'
stack traceback:
        [C]: in function 'require'
        t.lua:2: in main chunk
        [C]: in ?

  Notice how it keeps looking for gopher/icon.lua or gopher/icon/init.lua.

  It should look more like:

lua: res.lua:37: resource "gopher.icon" not found:
        no file "/home/spc/.luarocks/share/lua/5.3/org.conman.app.gopherclient/gopher.icon"
        no file "/home/spc/.luarocks/lib/lua/5.3/org.conman.app.gopherclient/gopher.icon"
        no file "/usr/local/share/lua/5.3/org.conman.app.gopherclient/gopher.icon"
        no file "/usr/local/lib/lua/5.3/org.conman.app.gopherclient/gopher.icon"
        no file "./org.conman.app.gopherclient/gopher.icon"
stack traceback:
        [C]: in function 'error'
        res.lua:37: in function 'resource'
        res.lua:40: in main chunk
        [C]: in ?

  -spc

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
It was thus said that the Great Sean Conner once stated:

>   It should look more like:
>
> lua: res.lua:37: resource "gopher.icon" not found:
>         no file "/home/spc/.luarocks/share/lua/5.3/org.conman.app.gopherclient/gopher.icon"
>         no file "/home/spc/.luarocks/lib/lua/5.3/org.conman.app.gopherclient/gopher.icon"
>         no file "/usr/local/share/lua/5.3/org.conman.app.gopherclient/gopher.icon"
>         no file "/usr/local/lib/lua/5.3/org.conman.app.gopherclient/gopher.icon"
>         no file "./org.conman.app.gopherclient/gopher.icon"
> stack traceback:
>         [C]: in function 'error'
>         res.lua:37: in function 'resource'
>         res.lua:40: in main chunk
>         [C]: in ?

  My mistake---there was a bug in the code [1] that didn't properly replace
the dots in the module name with directory separators.  It should look like:

lua: /tmp/foo/res.lua:37: resource "gopher.icon" not found:
        no file "/home/spc/.luarocks/share/lua/5.3/org/conman/app/gopherclient/gopher.icon"
        no file "/home/spc/.luarocks/lib/lua/5.3/org/conman/app/gopherclient/gopher.icon"
        no file "/usr/local/share/lua/5.3/org/conman/app/gopherclient/gopher.icon"
        no file "/usr/local/lib/lua/5.3/org/conman/app/gopherclient/gopher.icon"
        no file "./org/conman/app/gopherclient/gopher.icon"
stack traceback:
        [C]: in function 'error'
        /tmp/foo/res.lua:37: in function 'resource'
        /tmp/foo/res.lua:40: in main chunk
        [C]: in ?

  -spc

[1] Code?  Yes, I already have an implementation.  I'm not releasing it
        until we see an implementation from Soni.  It's all done in straight
        Lua.

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Griffin Rock
>From Sean Conner:
>   no file '/home/spc/.luarocks/share/lua/5.3/package:gopher/icon.lua'
>   [etc]
> This doesn't work because package.searchpath() isn't exactly what you want
> (read it closely).

Hmm, odd. It looks like your Lua is replacing the "." with the
directory separator, but it should be replacing the ":" instead.
What release of Lua are you running?

> My mistake---there was a bug in the code [1] that didn't properly replace
> the dots in the module name with directory separators.
> It's all done in straight Lua.

Wait... do you mean you are monkey-patching package.searchpath
(as opposed to 'require' or package.searchers)?
Can I ask why, or would that be a spoiler?
Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Sean Conner
It was thus said that the Great Griffin Rock once stated:
> >From Sean Conner:
> >   no file '/home/spc/.luarocks/share/lua/5.3/package:gopher/icon.lua'
> >   [etc]
> > This doesn't work because package.searchpath() isn't exactly what you want
> > (read it closely).
>
> Hmm, odd. It looks like your Lua is replacing the "." with the
> directory separator, but it should be replacing the ":" instead.
> What release of Lua are you running?

  Lua 5.1, 5.2 or 5.3---take your pick (mostly 5.3 these days, but I still
use 5.1 at work.  5.2 wasn't a compelling enough version for me to use).

> > My mistake---there was a bug in the code [1] that didn't properly replace
> > the dots in the module name with directory separators.
> > It's all done in straight Lua.
>
> Wait... do you mean you are monkey-patching package.searchpath
> (as opposed to 'require' or package.searchers)?
> Can I ask why, or would that be a spoiler?

  I added package.rpath to contain a list of directories to search for
resources based on a module name:

        package.rpath = "/usr/local/share/lua/5.3/?;..."

  I then added package.resources, an array of functions to load resources.
There's only one function so far, a function that uses package.rpath to
locate a resource file.  I then created a function resource(), callable
like:

        f = resource("org.conman.app.gopherclient","gopher.icon")

  It returns an open file object of said resource, or throws an error with the
output you saw.

  There's no clean way to base a search path for resources from either
package.path or package.cpath.  Yes, you can split it on
package.config:sub(3,3) to get each entry, and you can locate the
replacement marker by looking for package.config:sub(5,5) but after that,
there's no real way to clean it up, so that's why the new path (which Soni
even alluded to).  I could have added a new entry to package.searchers, but
then I would have to rewrite require() to pass two pieces of information to
each searcher function and at this point, I didn't feel that was warranted
(being lazy---hey, I'm not the one asking for this feature) so I went with a
separate package.resources array instead.

  -spc (And what I have does with with Lua 5.1 or higher ... )

Reply | Threaded
Open this post in threaded view
|

Re: [proposal] require resources

Soni "They/Them" L.
In reply to this post by Sean Conner


On 2020-01-20 1:39 a.m., Sean Conner wrote:

> It was thus said that the Great Soni They/Them L. once stated:
> > > On 2020-01-20 1:10 a.m., Sean Conner wrote:
> > >   It might seem like a simple request, but it's not.
> >
> > The same can be said of require.
> >
> > Again it would just be replacing patterns:
> >
> > icon = require("org.conman.app.gopherclient","gopher.icon")
> >
> > replace the left's .'s with /'s, add / at the end, add right at the end.
> >
> > if you had resource path /usr/lib/lua/5.4/? for example, it would try to
> > open /usr/lib/lua/5.4/org/conman/app/gopherclient/gopher.icon
>
>    Does it ever occur to you to actually *try* to implement your ideas?
>
>    This idea, with a separate resource path, could be done in pure Lua.  Add
> a package.rpath (for resource path), then replace require() to look for two
> parameters and handle it appropriately?  I know I made a similar change
> (adding a path, adding a new searcher function) to load C functions directly
> from source [1].  And then hey, post the code and get feedback.
>
>    -spc (Sigh)
>
> [1] https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.lua
>

Many things could be done in pure-Lua.

Python has importlib.resources, and I think it's a neat idea to be able
to handle resource packaging together with module packaging. It'd also
be much cleaner if it was part of the language IMO. This is why it's a
proposal and not an [ANN].

the whole proposal is "can we have this thing python has?" basically.