lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Here it is:
 
-----------
 
c:\temp>lua53 -E
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
Lua>tonumber(100,4)
stdin:1: bad argument #1 to 'tonumber' (string expected, got number)
stack traceback:
        [C]: in function 'tonumber'
        stdin:1: in main chunk
        [C]: in ?

c:\temp>lua52 -E
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
Lua>=tonumber(100,4)
16
-----------
 
The online manual for either case says that when base is present the number should be a string:
5.3: When called with base, then e must be a string to be interpreted as an integer numeral in that base.
5.2: When called with base, then e should be a string to be interpreted as an integer numeral in that base.
 
Although 5.3 conforms more strictly to the manual, 5.2’s flexibility is more practical -- avoids an extra tostring().
Is there a reason 5.3 lost this flexibility?  Could it get it back?