• 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: Is there a pattern for creating an object with global scope?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a pattern for creating an object with global scope?


  • Subject: Re: Is there a pattern for creating an object with global scope?
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 13 Apr 2013 20:51:50 -0700

On Apr 13, 2013, at 6:38 AM, Scott Ribe <email@hidden> wrote:

>> YT wants to create an object, which isn’t as straightforward because you can’t have an object literal in Objective-C. Instead you declare a global pointer and initialize it early on.
>
> Oh, right, I work in Objective-C++, so I don't have that limitation, and always forget about the plain C rules.

C++ static initializers are evil, though, at least the ones that run code. They run super early, in an undefined order, with no way to specify dependencies between them; so if you’re not careful they can slow down launch and/or cause weird nondeterministic bugs.

(I have spent time on at least one huge C++ project ripping out all static initializer functions/constructors, for exactly those reasons.)

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Is there a pattern for creating an object with global scope?
      • From: Scott Ribe <email@hidden>
    • Re: Is there a pattern for creating an object with global scope?
      • From: Allan Odgaard <email@hidden>
References: 
 >Is there a pattern for creating an object with global scope? (From: YT <email@hidden>)
 >Re: Is there a pattern for creating an object with global scope? (From: Scott Ribe <email@hidden>)
 >Re: Is there a pattern for creating an object with global scope? (From: Jens Alfke <email@hidden>)
 >Re: Is there a pattern for creating an object with global scope? (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: get return value from NSUserUnixTask
  • Next by Date: Re: multiple profiles in preferences mechanism
  • Previous by thread: Re: Is there a pattern for creating an object with global scope?
  • Next by thread: Re: Is there a pattern for creating an object with global scope?
  • Index(es):
    • Date
    • Thread