I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this? Also, is luajit used in the same way, or would it be possible to use a system installed luajit in building luatex? -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA/CoRA Division FAX: 303-415-9702 3380 Mitchell Lane orion@cora.nwra.com Boulder, CO 80301 http://www.cora.nwra.com
On Fri, Sep 25, 2015 at 4:09 PM, Orion Poplawski
I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this?
hm, the only relevant patch I can see here https://www.tug.org/svn/texlive/trunk/Build/source/libs/lua52/lua-5.2.4-PATC... is about utf-8 chars in names. For the rest, there are a bunch of libraries as lpeg that are embedded in the interpreter. The current manual is luatexref-t.pdf at foundry.supelec.fr/scm/viewvc.php/trunk/manual/luatexref-t.pdf?root=luatex&view=log Also, is luajit used in the same way, or would it be possible to use a
system installed luajit in building luatex?
Theoretically yes, but I dont know if the patches are still ok in this case. While we try to use the stock lua/luajit as much as possibile, the builder can decide to patch the source to match the TeXLive build requirements, and the luatex team can decide to modify the source to match the development requirements. Also we try to keep luajit as drop-in replacement of lua so that minimize the effort of adapting a format. Given the current status of luajit, the rule is not to depend on luajittex --- this means that the same task in luajittex should be done in luatex; usually luajittex is faster than luatex with jit off, but in some situations there is no gain, and it's better to use luatex then. -- luigi
On 09/25/2015 09:10 AM, luigi scarso wrote:
On Fri, Sep 25, 2015 at 4:09 PM, Orion Poplawski
mailto:orion@cora.nwra.com> wrote: I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this?
hm, the only relevant patch I can see here https://www.tug.org/svn/texlive/trunk/Build/source/libs/lua52/lua-5.2.4-PATC... is about utf-8 chars in names. For the rest, there are a bunch of libraries as lpeg that are embedded in the interpreter.
It's no so much the changes made to lua directly, but that luatex appears to make use of lua internals, e.g.: texk/web2c/luatexdir/lua/lstrlibext.c includes lapi.h which is not a public lua header. And texk/web2c/luatexdir/lua/texluac.w uses ldebug.h, ldo.h
The current manual is luatexref-t.pdf at foundry.supelec.fr/scm/viewvc.php/trunk/manual/luatexref-t.pdf?root=luatex&view=log http://foundry.supelec.fr/scm/viewvc.php/trunk/manual/luatexref-t.pdf?root=luatex&view=log
Thanks. -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA/CoRA Division FAX: 303-415-9702 3380 Mitchell Lane orion@cora.nwra.com Boulder, CO 80301 http://www.cora.nwra.com
On 9/25/2015 4:09 PM, Orion Poplawski wrote:
I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this?
Indeed we have some more on board. Keep in mind that lua is used as extension language so whenever it's used in an application there can be extensions. Btw, a dialect implies a different language. Adding a couple of functions is not making it a dialect.
Also, is luajit used in the same way, or would it be possible to use a system installed luajit in building luatex?
The only benefit of luajit is the faster virtual machine. A downside is that there are some limitations in memory cq. stack usage. We use a patch that makes the string hashing faster (we use the normal lua method instead of the luajit one that is optimizied for urls and that can make luajit slower than lua). Becaus eluatex uses lua as extension language it will always be shipped with a specific version (linked in or alongside the binary). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 09/25/2015 03:04 PM, Hans Hagen wrote:
On 9/25/2015 4:09 PM, Orion Poplawski wrote:
I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this?
Indeed we have some more on board. Keep in mind that lua is used as extension language so whenever it's used in an application there can be extensions.
Btw, a dialect implies a different language. Adding a couple of functions is not making it a dialect.
You appear to be extending it in at least four areas by adding new functions, and replacing some as described below. liolibext is the most "entangled" due to duplicating liolib code, lstrlibext also uses some Lua internals that are not normally exposed to consumers of Lua (e.g. lua_lock). I'm fine with not calling this a new "dialect", but it is certainly extended, though modifying popen()/read()/lines() is interesting. I'm interested to know if there has been any discussion with the Lua maintainers about incorporating any of these changes in Lua proper? liolibext.c: /* This extension only replaces one function: io.popen() and two metatable entries: f:read() and f:lines() but unfortunately it has to copy quite a bunch of lines from the original liolib.c to do so. */ llfslibext.c: adds to lfs: lua_setfield(L, -2, "isdir"); lua_pushcfunction(L, file_is_file); lua_setfield(L, -2, "isfile"); lua_pushcfunction(L, read_link); lua_setfield(L, -2, "readlink"); lua_pushcfunction(L, get_short_name); lua_setfield(L, -2, "shortname"); loslibext.c: lua_getglobal(L, "os"); lua_pushcfunction(L, ex_sleep); lua_setfield(L, -2, "sleep"); lua_pushliteral(L, OS_PLATTYPE); lua_setfield(L, -2, "type"); lua_pushliteral(L, OS_PLATNAME); lua_setfield(L, -2, "name"); lua_pushcfunction(L, ex_uname); lua_setfield(L, -2, "uname"); #if (! defined (_WIN32)) && (! defined (__SUNOS__)) lua_pushcfunction(L, os_times); lua_setfield(L, -2, "times"); #endif #if ! defined (__SUNOS__) lua_pushcfunction(L, os_gettimeofday); lua_setfield(L, -2, "gettimeofday"); #endif if (!safer) { lua_pushcfunction(L, os_setenv); lua_setfield(L, -2, "setenv"); lua_pushcfunction(L, os_exec); lua_setfield(L, -2, "exec"); lua_pushcfunction(L, os_spawn); lua_setfield(L, -2, "spawn"); lua_pushcfunction(L, os_execute); lua_setfield(L, -2, "execute"); lua_pushcfunction(L, os_tmpdir); lua_setfield(L, -2, "tmpdir"); } lstrlibext.c {"utfvalues", str_utfvalues}, {"utfcharacters", str_utfcharacters}, {"characters", str_characters}, {"characterpairs", str_characterpairs}, {"bytes", str_bytes}, {"bytepairs", str_bytepairs}, {"explode", str_split}, {"dump", str_dump},
Also, is luajit used in the same way, or would it be possible to use a system installed luajit in building luatex?
The only benefit of luajit is the faster virtual machine. A downside is that there are some limitations in memory cq. stack usage. We use a patch that makes the string hashing faster (we use the normal lua method instead of the luajit one that is optimizied for urls and that can make luajit slower than lua).
Becaus eluatex uses lua as extension language it will always be shipped with a specific version (linked in or alongside the binary).
Hans
FWIW - Here are some changes I had to make while trying to compile
against lua 5.3:
diff --git a/texk/web2c/luatexdir/lua/liolibext.c
b/texk/web2c/luatexdir/lua/liolibext.c
index edf094d..883dce7 100644
--- a/texk/web2c/luatexdir/lua/liolibext.c
+++ b/texk/web2c/luatexdir/lua/liolibext.c
@@ -33,6 +33,7 @@
#include "lauxlib.h"
#endif
#include "lualib.h"
+#include
On Sat, Sep 26, 2015 at 4:22 PM, Orion Poplawski
On 09/25/2015 03:04 PM, Hans Hagen wrote:
On 9/25/2015 4:09 PM, Orion Poplawski wrote:
I'm just starting to take a look how luatex makes use of lua. And it appears that luatex does not merely use lua, but extends it in various ways, essentially creating new lua dialect. Is the assessment correct? Is there any documentation on this?
Indeed we have some more on board. Keep in mind that lua is used as extension language so whenever it's used in an application there can be extensions.
Btw, a dialect implies a different language. Adding a couple of functions is not making it a dialect.
You appear to be extending it in at least four areas by adding new functions, and replacing some as described below. liolibext is the most "entangled" due to duplicating liolib code, lstrlibext also uses some Lua internals that are not normally exposed to consumers of Lua (e.g. lua_lock). I'm fine with not calling this a new "dialect", but it is certainly extended, though modifying popen()/read()/lines() is interesting. I'm interested to know if there has been any discussion with the Lua maintainers about incorporating any of these changes in Lua proper?
liolibext.c: /* This extension only replaces one function: io.popen() and two metatable entries: f:read() and f:lines() but unfortunately it has to copy quite a bunch of lines from the original liolib.c to do so. */
llfslibext.c: adds to lfs: lua_setfield(L, -2, "isdir"); lua_pushcfunction(L, file_is_file); lua_setfield(L, -2, "isfile"); lua_pushcfunction(L, read_link); lua_setfield(L, -2, "readlink"); lua_pushcfunction(L, get_short_name); lua_setfield(L, -2, "shortname");
loslibext.c: lua_getglobal(L, "os"); lua_pushcfunction(L, ex_sleep); lua_setfield(L, -2, "sleep"); lua_pushliteral(L, OS_PLATTYPE); lua_setfield(L, -2, "type"); lua_pushliteral(L, OS_PLATNAME); lua_setfield(L, -2, "name"); lua_pushcfunction(L, ex_uname); lua_setfield(L, -2, "uname"); #if (! defined (_WIN32)) && (! defined (__SUNOS__)) lua_pushcfunction(L, os_times); lua_setfield(L, -2, "times"); #endif #if ! defined (__SUNOS__) lua_pushcfunction(L, os_gettimeofday); lua_setfield(L, -2, "gettimeofday"); #endif
if (!safer) { lua_pushcfunction(L, os_setenv); lua_setfield(L, -2, "setenv"); lua_pushcfunction(L, os_exec); lua_setfield(L, -2, "exec"); lua_pushcfunction(L, os_spawn); lua_setfield(L, -2, "spawn"); lua_pushcfunction(L, os_execute); lua_setfield(L, -2, "execute"); lua_pushcfunction(L, os_tmpdir); lua_setfield(L, -2, "tmpdir"); }
lstrlibext.c {"utfvalues", str_utfvalues}, {"utfcharacters", str_utfcharacters}, {"characters", str_characters}, {"characterpairs", str_characterpairs}, {"bytes", str_bytes}, {"bytepairs", str_bytepairs}, {"explode", str_split}, {"dump", str_dump},
Also, is luajit used in the same way, or would it be possible to use a
system installed luajit in building luatex?
The only benefit of luajit is the faster virtual machine. A downside is that there are some limitations in memory cq. stack usage. We use a patch that makes the string hashing faster (we use the normal lua method instead of the luajit one that is optimizied for urls and that can make luajit slower than lua).
Becaus eluatex uses lua as extension language it will always be shipped with a specific version (linked in or alongside the binary).
Hans
FWIW - Here are some changes I had to make while trying to compile against lua 5.3:
Thank you for the patches --- do they also work for luajittex ?
-- luigi
On 09/26/2015 10:38 AM, luigi scarso wrote:
On Sat, Sep 26, 2015 at 4:22 PM, Orion Poplawski
mailto:orion@cora.nwra.com> wrote: FWIW - Here are some changes I had to make while trying to compile against lua 5.3: Thank you for the patches --- do they also work for luajittex ?
I really don't know, didn't get that far. -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA/CoRA Division FAX: 303-415-9702 3380 Mitchell Lane orion@cora.nwra.com Boulder, CO 80301 http://www.cora.nwra.com
Il 26/set/2015 20:33, "Orion Poplawski"
On 09/26/2015 10:38 AM, luigi scarso wrote:
On Sat, Sep 26, 2015 at 4:22 PM, Orion Poplawski
mailto:orion@cora.nwra.com> wrote: FWIW - Here are some changes I had to make while trying to compile against lua 5.3: Thank you for the patches --- do they also work for luajittex ?
I really don't know, didn't get that far.
It should be a matter of build.sh --jit Eventually source/rebuild to have the right configure files.
participants (3)
-
Hans Hagen
-
luigi scarso
-
Orion Poplawski