Re: loop efficiency & messages
Re: loop efficiency & messages
- Subject: Re: loop efficiency & messages
- From: "Corey O'Connor" <email@hidden>
- Date: Tue, 22 Mar 2005 13:52:11 -0800
> On the other hand, though, what you (I bet) *wanted* to ask was "is
> there any way to declare an ObjC *message* to behave this way", and
> here the answer is "of course not". Messages are fully dynamic: that's
> something C++ just does not support at all. The compiler can never know
> (and, speaking of that, the programmer who writes the code can neither)
> who would actually catch the message. It might be overridden using a
> category or a posedAsClass or whatever...
hehe. Yes, that is what I wanted to ask. The compiler certainly
couldn't infer from that code whether or not the destination of the
message will remain constant throughout the loop. However, I could
imagine this would be a desirable feature. I think MuleKybernetic (?)
had an article on "selector caching", or such, that discussed how to
solve this particular problem. I dunno if I'd consider their technique
a compile-time feature however.
> Nevertheless, that are not quite important technicalities. What *is*
> important is that you just do not need this kind of optimization.
Not in anything I'd use the Objective-C messaging system for. The
domains in which the abstractions provided by messages are useful are
not the same as the ones in which I'm worried about the performance of
a simple for loop. There have been times where __attribute__ and const
have made a significant difference in performance. Usually in some
tight loop deep in the bowels of some computation.
Before anybody beats me to the usually optimization disclaimer:
Optimizing by fiddling with __attribute__, selector caching, or
anything else that sacrifices flexibility for performance is the
*last* thing anybody should try. As always: Features first,
performance second. :-) Still, when evaluating what implementation
language to choose, sometimes performance considerations are
important. In that case, choosing the wrong language could be costly.
--
-Corey O'Connor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden