lua-users home
lua-l archive

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

2013/7/17 Roberto Ierusalimschy <>:
>> On Wed, Jul 17, 2013 at 10:10 AM, David Demelier
>> <>wrote:
>> > type(10) -> "number", "integer"
>> > type(10.0) -> "number", "float"
>> >
>> > This is not a bad idea, it will not break compatibility but adds a
>> > second feature to determine the actual type of the integer.
> I do not think it is a good idea. If something is an integer, it must
> be a number, so the first result is useless when you want the second.
> And to simply check whether something is an integer you will need extra
> local variables or 'select', to access that second result.
>> (Saying this because string.gsub is always biting me this way)
> That was not a good idea, either :)
> We moved that functionality to a new function, debug.subtype, that
> returns the following: integer, float, Cfunction, Luafunction,
> lightudata, fulludata, string, boolean, nil, table, and thread.
> Some of that functionality may not be strictly "debug", but anyway
> it is something you should not be using every day, and we could not
> find a better place to put that function; it may move to the global
> space...
> (In an ideal world, probably we should have a library with those
> functions we do not use every day (maybe with rawget, rawset,
> getmetatable, setmetatable, collectgarbage, and some others), but I do
> not think the change is worth the trouble. Just imagine the endless
> discussions about what functions should go there...)
> -- Roberto

So math.isfloat and math.isinteger looks the better place to add these
functions IMHO :-)


Demelier David