[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: "usertype()" function
- From: Geoff Leyland <geoff_leyland@...>
- Date: Thu, 31 May 2012 16:42:07 +1200
On 31/05/2012, at 4:00 PM, Miles Bader wrote:
> Something like type predicates would be much better. So the trick is,
> assuming a standard set of type predicates, how do you extend them to
> work on user types?
Does the typeinfo function I suggested earlier count as a predicate? You could call it "istype" if that helped: istype(obj).typename. One feature of returning at table is that the return value of typeinfo can be cached:
local t = typeinfo(obj)
if t.string then
...
elseif t.number then
...
elseif t.mytype then
...
end