FROM : Ondra Cada
DATE : Sun Nov 10 20:09:13 2002
On Sunday, November 10, 2002, at 05:20 , Ken Tozier wrote:
> I was reading up on how to use IMP in the NSObject documentation in
> order to speed up some of my loops, but the examples don't look right.
They do.
> The documentation suggested declaring IMP's like this:
> ...
> And using them like this:
>
> while ( !test(target, @selector(isEqual:), someObject) )
...
> But given that the initialization line:
>
> test = (EqualIMP)[target methodForSelector:@selector(isEqual:)];
>
> already encapsulates "id" and "SEL" from the prototype,
It does not. It just uses an id and SEL to find the implementation, which
is a plain function pointer. So far as the function's first argument is an
id and second a SEL, you have to provide them. That's all.
> I would have
> expected it to be used like:
>
> while ( !test(someObject) )
> ...
>
> What's the scoop?
I guess you are looking for a complexity which does not exist. IMP is just
a pointer, but for the function adress it encapsulates *nothing*.
---
Ondra Cada
OCSoftware: <email_removed> http://www.ocs.cz
private <email_removed> http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Sun Nov 10 20:09:13 2002
On Sunday, November 10, 2002, at 05:20 , Ken Tozier wrote:
> I was reading up on how to use IMP in the NSObject documentation in
> order to speed up some of my loops, but the examples don't look right.
They do.
> The documentation suggested declaring IMP's like this:
> ...
> And using them like this:
>
> while ( !test(target, @selector(isEqual:), someObject) )
...
> But given that the initialization line:
>
> test = (EqualIMP)[target methodForSelector:@selector(isEqual:)];
>
> already encapsulates "id" and "SEL" from the prototype,
It does not. It just uses an id and SEL to find the implementation, which
is a plain function pointer. So far as the function's first argument is an
id and second a SEL, you have to provide them. That's all.
> I would have
> expected it to be used like:
>
> while ( !test(someObject) )
> ...
>
> What's the scoop?
I guess you are looking for a complexity which does not exist. IMP is just
a pointer, but for the function adress it encapsulates *nothing*.
---
Ondra Cada
OCSoftware: <email_removed> http://www.ocs.cz
private <email_removed> http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Ken Tozier | Nov 10, 05:20 | |
| John Hörnkvist | Nov 10, 18:22 | |
| Ondra Cada | Nov 10, 20:09 | |
| Marcel Weiher | Nov 10, 21:13 |






Cocoa mail archive

