[luatex] First (optional?) arguments of tex.getcount and friends.
taco at elvenkind.com
Tue May 10 19:47:10 CEST 2011
Op 10 mei 2011 om 17:36 heeft Philipp Stephani <st_philipp at yahoo.de> het volgende geschreven:
> Am 10.05.2011 um 15:44 schrieb Taco Hoekwater:
>> On 05/10/2011 03:42 PM, Paul Isambert wrote:
>>> Hello all,
>>> I have noticed that the function tex.getcount() and similar can take any
>>> number of arguments and ignore them all but the last. E.g.:
>>> texio.write_nl(tex.getcount("a string", nothing, node.new(11), 55, 0))
>>> returns "1", i.e. the value of count 0, ignoring the string, the nil
>>> value, the node, and the number.
>>> Is that normal? Am I missing something? My LuaTeX is 0.71.
>> I am not surprised: lua pushes the arguments on a stack, and then the
>> getcount function takes the topmost entry.
> Yes, but that is the first argument, not the last. Lua functions ignore any additional arguments that are appended to the argument list, but not those that are prepended. Maybe some sign error? 1 instead of -1?
> $ lua - <<< 'function test(foo) print(foo) end test(1, 2, 3)'
Well, getcount does what i wrote. top of stack is the item at 5 in your initial example, and you get that top of stack value by using the index -1 as argument to the lua interface function that fetches stack values. You may not like that, but that it is what happens currently, and it is not by mistake.
More information about the luatex