[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: "usertype()" function
- From: Geoff Leyland <geoff_leyland@...>
- Date: Fri, 1 Jun 2012 07:44:50 +1200
On 1/06/2012, at 2:33 AM, Coda Highland wrote:
> On Thu, May 31, 2012 at 12:03 AM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
>> On 31/05/2012, at 4:52 PM, Coda Highland wrote:
>>
>>> I'd like it better if it were t.is(string), because then you're not
>>> using strings for type matching but instead confirming the actual type
>>> object.
>>
>> What's your objection to strings?
>
> Namespace collisions
Good point. I've only used this is in code I control, so that problem didn't come up.
> but why use strings when you don't have to?
Avoiding requiring modules. If type A is defined in module A, and you want to check for it in module B, then you have to require module A in module B before you can typeinfo(obj)[A], but with strings you can do a typeinfo(obj).A without requiring anything.
As I said before, there's no problem putting metatables and/or strings in the typeinfo table for an object.
Cheers,
Geoff