This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lignum's profile picture

What's up with the select function?

Started by Lignum, 14 February 2015 - 02:54 PM
Lignum #1
Posted 14 February 2015 - 03:54 PM
As you probably know, calling tostring on a function will return something along the lines of "function: xxxxxx".
Now, take a look at this:

lua> tostring(select)
select
lua> type(select)
function

This is really strange, all functions seem to follow the aforementioned rule except for select. Does anyone know what's going on here?
SquidDev #2
Posted 14 February 2015 - 04:36 PM
This is because it is a lua builtin. A non-comprehensive list of functions that follow this is as follows:

assert
error
ipairs
loadstring
next
pairs
pcall
rawequal
rawget
rawset
select
setfenv
setmetatable
tonumber
tostring
type
unpack
xpcall

This is a list of functions defined by LuaJ in Java, rather than functions defined in Lua. However Computer craft functions don't obey this rule.
Edited on 14 February 2015 - 03:38 PM
Lignum #3
Posted 14 February 2015 - 05:03 PM
Ah, yes, that is indeed the case. I've never noticed that the builtins did this. Thanks!