Re: loop efficiency & messages
Re: loop efficiency & messages
- Subject: Re: loop efficiency & messages
- From: Ondra Cada <email@hidden>
- Date: Tue, 22 Mar 2005 22:28:19 +0100
On 22.3.2005, at 22:10, Corey O'Connor wrote:
On Tue, 22 Mar 2005 21:49:52 +0100, Ondra Cada <email@hidden> wrote:
Does compiler optimize this similar to a C++ inline so that count is
just stored in a register, or does a message sequence happen each
time?
Very bad idea. If it did this "optimization", it would be a *very
grave
bug*. There's no way the compiler can ever know the value returned
would not change the next time the message is sent.
I believe, in C++, if you had something like this:
UInt16 Foo(const UInt16 inX, const UInt16 inY) __attribute__ ((pure));
...
Is there anyway to declare an objective-c function to be, similarly, a
"pure" function?
Well... the correct answer to the question is Yes, since you of course
can use the pure function in ObjC (just like anything other: ObjC is a
C superset).
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...
Nevertheless, that are not quite important technicalities. What *is*
important is that you just do not need this kind of optimization.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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