> On May 30, 2014, at 11:34 AM, Argyrios Kyrtzidis <[email protected]> wrote:
> 
> 
>> On May 30, 2014, at 11:13 AM, jahanian <[email protected]> wrote:
>> 
>> Is this intentional, or a specific case for retain/release methods?
> 
> This also returns TRUE:
> 
>       blk b = ^{};
>       BOOL res = [b respondsToSelector:@selector(isKindOfClass:)];
> 
> So blocks seem to respond to NSObject protocol selectors.
> 
>> In generally though it makes no sense
>> to allow qualified id conversion of blocks pointers.
> 
> It would make sense for id<NSObject> if we would guarantee that blocks 
> conform to NSObject protocol.

BTW, returns true as well:

        blk b = ^{};
        BOOL res = [b conformsToProtocol:@protocol(NSObject)];


> 
>> - Fariborz
>> 
>> On May 30, 2014, at 11:06 AM, Argyrios Kyrtzidis <[email protected]> wrote:
>> 
>>> I’m mainly asking if blocks are implicitly implementing the NSObject 
>>> protocol or not, for example this seems to work:
>>> 
>>> typedef void(^blk)(void);
>>> 
>>> int main() {
>>>     blk b = ^{};
>>>     BOOL res = [b respondsToSelector:@selector(retain)];
>>>     printf("res: %d\n", res);
>>>     return 0;
>>> }
>>> 
>>> 
>>>> On May 30, 2014, at 11:03 AM, Jordan Rose <[email protected]> wrote:
>>>> 
>>>> I think I agree with Fariborz on this one. I don't remember us ever 
>>>> promising that blocks implement the NSObject protocol, just that they are 
>>>> valid Objective-C objects and that they implement -retain, -release, and 
>>>> -copy. The spec on the Clang site doesn't even promise -retain. 
>>>> (http://clang.llvm.org/docs/BlockLanguageSpec.html#objective-c-extensions)
>>>> 
>>>> The developer can always cast if they really need this.
>>>> 
>>>> Jordan
>>>> 
>>>> 
>>>> On May 30, 2014, at 10:49 , jahanian <[email protected]> wrote:
>>>> 
>>>>> It makes no sense to assign block to an object conforming to protocols.
>>>>> Such objects must implement methods of those protocols which  blocks 
>>>>> cannot.
>>>>> I explicitly ruled this out. Did you see this in an actual user code? 
>>>>> Curious to see how it is being used.
>>>>> 
>>>>> - Fariborz
>>>>> 
>>>>> On May 30, 2014, at 10:32 AM, Argyrios Kyrtzidis <[email protected]> 
>>>>> wrote:
>>>>> 
>>>>>> This is giving an error in the following case, is this correct ?
>>>>>> 
>>>>>> #import <Foundation/Foundation.h>
>>>>>> 
>>>>>> typedef void(^blk)(void);
>>>>>> 
>>>>>> void foo(blk b) {
>>>>>>  id<NSObject> x = b; // error: initializing 'id<NSObject>' with an 
>>>>>> expression of incompatible type 'blk' (aka 'void (^)(void)')
>>>>>> }
>>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> cfe-commits mailing list
>>>>> [email protected]
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>> 
>>> 
>> 
> 


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to