[lltx] lualatex-math cannot find unpack function

Reinhard Kotucha reinhard.kotucha at web.de
Mon Aug 5 21:39:58 CEST 2013


On 2013-08-05 at 17:51:04 +0300, Wolfgang Jeltsch wrote:

 > Am Samstag, den 03.08.2013, 21:21 +0200 schrieb Philipp Gesang:
 > > ááá<date: 2013-08-03, Saturday>ááá<from: Wolfgang Jeltsch>ááá
 > > > I think I have found the source of the problem. In Lua 5.1, unpack is a
 > > > global function, while in Lua 5.2, it is a field of the global variable
 > > > table. To ensure compatibility with both Lua versions, some Lua files
 > > > (lualibs-basic-merged.lua, lualibs-lua.lua, and luaotfload-merged.lua)
 > > > contain the following code:
 > > > 
 > > >     if not table.unpack then
 > > >       table.unpack=_G.unpack
 > > >     elseif not unpack then
 > > >       _G.unpack=table.unpack
 > > >     end
 > > 
 > > Packages shouldnÕt write to _G.
 > 
 > IÕm aware that this is an ugly hack, not only because _G is modified,
 > but also because table is modified. I think it would be more appropriate
 > to use a local variable unpack defined as follows:
 > 
 >     local unpack
 >     if table.unpack then
 >         unpack = table.unpack
 >     else
 >         unpack = _G.unpack
 >     end

I don't think that it's wrong to provide table.unpack if it doesn't
exist already.  LuaTeX already extends the string library similarly
(string.explode).

Since Lua 5.2 provides table.unpack we should be able to rely on it.
If it's necessary at all to support an older LuaTeX, it should be
sufficient to copy the global unpack to table:

  if not table.unpack then 
    table.unpack=unpack
  end

Ideally this is done at the very beginning.  It's still possible then
to say

  local unpack=table.unpack

but it's not necessary to do it globally.  You may want to create a
local unpack within a function definition or a do-block.

I'm not sure whether it's necessary to support Lua 5.1 here since TeX
Live 2012 is frozen.  Backwards compatibility makes only sense if
there is a severe bug in TL-2012.

Regards,
  Reinhard


 > > > I will send a patch to Philipp Stephani.
 > > 
 > > Fyi IÕve already sent him a pull request.
 > 
 > Thank you.
 > 
 > Best wishes,
 > Wolfgang
 > 

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------



More information about the lualatex-dev mailing list