[Dev-luatex] select()

Reinhard Kotucha reinhard.kotucha at web.de
Wed Feb 3 03:06:08 CET 2010


Hi,
I encountered a problem with select() in beta-0.40.6-2009100509 
(TeX Live 2009):

------------------------------------------------------------------
#! /usr/bin/env texlua

print (select (1, string.gsub ('abc', 'b', 'X')))
print (select (2, string.gsub ('abc', 'b', 'X')))
------------------------------------------------------------------

 --> aXc	1
 --> 1

This seems to be wrong.  select (1, ....) should only return the first
argument, not both.  I'm wondering why select (2, ....) works as
expected.  I must admit that I couldn't find any specs for select(),
it just appears in some examples in the Lua book.

I can define select() myself, overwriting the built-in function.
Then I get the results I expect:

------------------------------------------------------------------
#! /usr/bin/env texlua

function select (n, ...)
   return arg[n]
end

print (select (1, string.gsub ('abc', 'b', 'X')))
print (select (2, string.gsub ('abc', 'b', 'X')))
------------------------------------------------------------------

 --> aXc
 --> 1

Bug or feature?

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
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 dev-luatex mailing list