[Proposal] Canonical Module Names

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

[Proposal] Canonical Module Names

Soni "They/Them" L.
if you have foo/init.lua you can require it as either "foo" or
"foo.init" and I think lua should detect these and error if you don't
use the shorter one.

it's quite trivial to check this in the searchers themselves.
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] Canonical Module Names

Jonathan Goble
On Wed, Jun 10, 2020 at 10:52 PM Soni "They/Them" L. <[hidden email]> wrote:
if you have foo/init.lua you can require it as either "foo" or
"foo.init" and I think lua should detect these and error if you don't
use the shorter one.

it's quite trivial to check this in the searchers themselves.

If it's that trivial, then write your own searcher and replace the stock searchers with it. The code for the existing ones is in loadlib.c.
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] Canonical Module Names

Andrew Gierth
In reply to this post by Soni "They/Them" L.
>>>>> "Soni" == Soni \"They/Them\" L <[hidden email]> writes:

 Soni> if you have foo/init.lua you can require it as either "foo" or
 Soni> "foo.init" and I think lua should detect these and error if you
 Soni> don't use the shorter one.

Why not just put

assert(not string.match((...),"%.init$"), "wrong name")

near the top of your init.lua?

--
Andrew.