[luatex] print versus tex.print

Paul Isambert zappathustra at free.fr
Mon Jan 23 23:41:37 CET 2012


Reinhard Kotucha <reinhard.kotucha at web.de> a écrit:
> 
> On 2012-01-23 at 17:32:37 +0100, Paul Isambert wrote:
> 
>  > Herbert Voss <Herbert.Voss at fu-berlin.de> a écrit:
>  > > 
>  > > Am 23.01.2012 15:47, schrieb Paul Isambert:
>  > > 
>  > > >> \directlua{table.foreach(os.date("!*t"),function(...)
>  > > >> tex.print(tostring(...) end)}
>  > > >> \bye
>  > > >
>  > > > Or use a test like "type(<arg>) == 'boolean'". Note that table.foreach
>  > > 
>  > > I alread had tostring() but I thought there might be
>  > > an easier solution.
>  > > 
>  > > > is deprecated in Lua 5.1 and should be removed from 5.2 (see:
>  > > > http://lua-users.org/lists/lua-l/2010-11/msg00661.html). And LuaTeX
>  > > 
>  > > oh, I like that ... :-(
>  > 
>  > You can easily fake it:
>  > 
>  > table.foreach = table.foreach or
>  >   function (t, f)
>  >     for k, v in pairs(t) do
>  >       local ret = f(k, v)
>  >       if ret then return ret end
>  >     end
>  >   end
>  > 
>  > table.foreachi = table.foreach or
>  >   function (t, f)
>  >     for k, v in ipairs(t) do
>  >       local ret = f(k, v)
>  >       if ret then return ret end
>  >     end
>  >   end
> 
> AFAIK, ipairs() is deprecated in Lua 5.2 too.

No, it's not, there even are new metamethods __ipairs and __pairs. See:
http://www.lua.org/manual/5.2/readme.html#changes
(You frightened me for a second.)

Paul



More information about the luatex mailing list