Re: Toll-free bridge type at runtime
Re: Toll-free bridge type at runtime
- Subject: Re: Toll-free bridge type at runtime
- From: Michael Ash <email@hidden>
- Date: Sat, 4 Apr 2009 15:19:35 -0400
On Sat, Apr 4, 2009 at 3:10 PM, Marcel Weiher <email@hidden> wrote:
>
> On Apr 3, 2009, at 13:24 , Michael Ash wrote:
>>
>> As far as I can tell, what you're saying is that NSCFArray == CFArray.
>> In which case it is *still* impossible to distinguish an NSArray from
>> a CFArray, and still nonsensical to want to.
>>
>> But clearly that is not correct, since you keep saying that it is
>> trivial to distinguish them. So, please fill out the following
>> function:
>>
>> NSString *IsNSOrCFArray(id foo) // returns @"NSArray" or @"CFArray"
>> {
>> ....
>> }
>>
>> And also please indicate what this function should return for
>> IsNSOrCFArray([NSArray array]).
>
> That function template has nothing to do with what I was saying, so I don't
> see why I should fill it in. I have been saying that it is trivial to
> distinguish non-NSCFArray NSArrays from CFArray, and have given code that
> does so. I have not said that it is possible to distinguish *all* NSArrays
> from CFArray, because that is clearly non-sensical as *some* NSArrays are
> CFArrays (just not all of them as would be necessary for your claim to be
> true that NSArray and CFArray are in fact indistinguishable).
>
> That you are so vehement made me wonder wether I wrote sloppily, but
> reviewing my very first post on this topic, the distinction seems very clear
> and explicitly stated just as above (corrected "as" to "ask"):
>
> On Apr 2, 2009, at 12:20 , Marcel Weiher wrote:
>
>> An NSCFArray and a CFArray are indistinguishable as described, and if you
>> ask for an NSArray, you will typically get an NSCFArray.
>>
>> However, an actual NSArray that is not an NSCFArray will be different and
>> distinguishable. This distinction is also not just academic, but quite
>> important because it is used by CoreFoundation to know wether to call its
>> own functions or send a message to the object in question, allowing custom
>> NSArray subclasses to be used in CFArray calls.
>
> So once again:
>
> 1. An NSCFArray and a CFArray indistinguishable as you claim (and
> no-one ever claimed different)
> 2. A non-NSCFArray NSArray and a CFArray are trivially distinguishable,
> as I've demonstrated
>
> Your responses seem to indicate that I am saying "NSAray != CFArray" for all
> NSArray, or that there is a test that can ALWAYS distinguish an NSArray from
> a CFArray, but that is clearly not what I am saying. I am and have been
> saying that "NSArray = CFArray is false" and that there exists a test that
> can distinguish non-NSCFArray NSArrays from CFArrays. If you recall your
> basic logic, you will remember that the two are not the same thing.
Well, here's what you said in one of your messages:
>>> So the compiler also disagrees with you that these are the same type. You
>>> can *cast* them to be compatible, but they are not the same type.
>>
>> Right, but the original question was about figuring out what they are
>> at runtime which I don't believe is possible and it's not clear to me
>> whether you think it is possible.
>
> As I explained, it is trivially possible, because the only Objective-C class that
> is the same as its underlying CFType is NSCFArray.
That last sentence is you. The previous context is "distinguishing
between NSArray and CFArray". The "because" doesn't make any sense,
because you are actually addressing a different point: differentiating
between NSCFArray (which you see as being the same as CFArray) and
*other* NSArray subclasses.
So, yes, you were pretty sloppy here. You took the question at hand,
formed a completely different question, answered *that* one, and were
not very clear about the change of course you made. Given that you
were talking about question A and everybody else was talking about
question B, a gross misunderstanding is inevitable.
Your claim that NSCFArray can be distinguished from other NSArray
subclasses is obvious. This still has no bearing on "distinguishing
between NSArray and CFArray". It's a substantially different, if
related, idea.
It is clear that you agree that "distinguishing between NSArray and
CFArray" is nonsensical. You say as much in your message here. It is
also clear that I agree that "distinguishing between NSCFArray and
other NSArray subclasses" is trivial, I admit it right here. What I
don't understand is why you've kept up arguing with people over the
second one when we've only been talking about the first, but there it
is.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden