• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Future Objective-C changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Future Objective-C changes
      • From: Ben Dougall <email@hidden>
    • Re: Future Objective-C changes
      • From: Marcel Weiher <email@hidden>
  • Prev by Date: Re: Future Objective-C changes
  • Next by Date: Re: Encapsulating methods in ObjC
  • Previous by thread: Re: Need Help with Obj-C -> Java bridge method calls with multiple arguments
  • Next by thread: Re: Future Objective-C changes
  • Index(es):
    • Date
    • Thread