Jump to content




What's up with the select function?


  • You cannot reply to this topic
2 replies to this topic

#1 Lignum

  • Members
  • 558 posts

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?

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

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 by SquidDev, 14 February 2015 - 04:38 PM.


#3 Lignum

  • Members
  • 558 posts

Posted 14 February 2015 - 05:03 PM

Ah, yes, that is indeed the case. I've never noticed that the builtins did this. Thanks!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users