Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Joe Chan <email@hidden>
- Date: Wed, 21 May 2003 09:59:54 -0400
Still just one save/restore. Objects are good.
(1) Because it has nothing to do with the stack-frame (2) because you
are achieving the effect by *declaring a local variable*. Notice the
part about "declaring"...
Actually I'm "defining" a local variable,
Gosh, this sure looks like a declaration to me, and just strengthens my
point. How can I tell the difference by looking at the code? How is
the code intention-revealing?
Actually it is a definition. A statement such as
int i;
is both a definition and declaration. It not only declare the type of
the variable, it also provide storage for it. Imagine this is a global
variable, it'll be the definition of the global variable. To declare
without defining it would be
extern int i;
which does not allocate any storage. I don't think it's possible to
only declare a local variable with defining it also.
and a defining local variable is nothing more than attaching some bit
of data to the local stack frame, so it has *everything* to do with
the local stack frame.
Exactly! *Declaring* the local variable has something to do with the
*local stack frame*. It has NOTHING whatsoever to do with modifying
*global* state.
On the other hand, the global graphics state has nothing to do with the
local stack-frame.
Regardless of it's merit, it's a common C++ idiom for writing exception
safe code. Most C++ programmers will find this quite natural. Of
course, in an Obj-C world now where such idiom looks rather unnatural,
since there is no stack based objects. This is one reason I never liked
Obj-C++ to begin with, it just confuses both Obj-C and C++ folks.
--
Joe Chan
Sun Microsystems, Inc.
Burlington, MA
Tel: (781) 442-0809
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.