[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.3 work1 Considering math.isinteger or type()
- From: Miles Bader <miles@...>
- Date: Tue, 23 Jul 2013 10:59:07 +0900
"John Hind" <email@example.com> writes:
> Still seems to me that a second return value from type() is by far the most
> straight forward solution to this. Anyone who does not like this can easily
> front it with a wrapper in Lua to do it however they wish.
I disagree, I think the current math.isinteger (with a possible
math.isfloat alternative) is better.
In general I think predicates are more useful than "type()" type
operators, because they avoid the need to partition the input space,
and correspond more exactly with what the user typically wants to
know: does this objects have <interface/behavior X>.
So basically I think the existing interface in 5.3-work1 is fine, and
a good model to follow.
p.s. I _also_ think that a similar model (isfunction(), istable(),
etc) would be better for general Lua type inquiries than type(); see
various long past threads on this mailing list... :]
"An atheist doesn't have to be someone who thinks he has a proof that
there can't be a god. He only has to be someone who believes that the
evidence on the God question is at a similar level to the evidence on
the werewolf question." [John McCarthy]