Hyphens in module names & -l option

"'Michal Domonkos' via lua-l" <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <ad9xz8jbFSIoungt@thinkpad>
Hi there,

Commit 09f3c2372f5dbeaec9f50614a26c1b5761726a88 made the -l CLI option discard
a version suffix, if any, delimited by the LUA_IGMARK (hyphen). Howevever, that
means, module names that contain a hyphen in the name (which doesn't delimit a
version suffix), such as "lua-utf8", will now have the suffix part stripped on
import, too. For example, before the patch:

    $ lua -v
    Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio

    $ lua -l lua-utf8 -e 'print(_G["lua-utf8"].len("test"))'
    4

Whereas on with the patch, the module is added as "lua" to the global table,
and thus the same command now fails:

    $ lua -v
    Lua 5.4.8  Copyright (C) 1994-2025 Lua.org, PUC-Rio

    $ lua -l lua-utf8 -e 'print(_G["lua-utf8"].len("test"))'
    lua: (command line):1: attempt to index a nil value (field 'lua-utf8')
    stack traceback:
            (command line):1: in main chunk
            [C]: in ?

    $ lua -l lua-utf8 -e 'print(_G["lua"].len("test"))'     # "lua" works
    4

Now, the following alternative (and perhaps more common?) methods of importing
a module work fine with both versions:

    $ lua -l u=lua-utf8 -e 'print(u.len("test"))'
    4
    $ lua -e 'local u = require("lua-utf8"); print(u.len("test"))'
    4

So I'm wondering: were such hyphen-ated names considered with that -l behavior
change, and if not, is it a common enough use case that the patch potentially
breaks the stability promise of the 5.4 version?

Thanks,

-- 
Michal Domonkos / RPM.org / Red Hat

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/ad9xz8jbFSIoungt%40thinkpad.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.