[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.3 work1 Considering math.isinteger or type()
- From: Andrew Starks <andrew.starks@...>
- Date: Wed, 17 Jul 2013 11:10:14 -0500
On Wed, Jul 17, 2013 at 8:26 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> On Wed, Jul 17, 2013 at 10:10 AM, David Demelier
>> <demelier.david@gmail.com>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
>
>
I hate to call it a different type, but could yo add to this list "not
declared"/"invalid key" (or similar) for values in a table that are
not declared at all.
I don't wish to bring a prior thread (nil/empty) into this one, but
the distinction is just as real and some times as relevant as the
others that you've highlighted.
-Andrew