Re: Bundle loading
Re: Bundle loading
- Subject: Re: Bundle loading
- From: Douglas Davidson <email@hidden>
- Date: Thu, 22 Aug 2002 09:44:16 -0700
On Thursday, August 22, 2002, at 05:03 AM, Chris Ridd wrote:
Does loading a bundle in cause any code to get executed in the bundle
automatically, or any other kind of automatic initialization?
Basically if I write a bundle, how do I make sure that some kind of
initialization that I may require happens?
The docs are pretty unclear on this, as they seem to be mostly written
from
the point of view of the code loading the bundle in.
A bundle can contain any of a number of different types of
executables--for example, an application bundle can contain a Mach-o or
PEF executable, a framework bundle contains a Mach-o MH_DYLIB, a
loadable bundle can contain a Mach-o MH_BUNDLE or a loadable PEF
executable. The semantics of bundle loading depend on the type of
executable. Some types of executables, such as application main
executables, cannot be dynamically loaded at all. For those
executables that can be loaded, the behavior at load time depends on
the behavior of the underlying runtime. This in turn may vary
depending on the type of executable--for example, both Mach-o MH_DYLIBs
and MH_BUNDLEs can be loaded, but they have somewhat different
semantics at load time. Please look at the runtime architecture
documentation for more information.
That said, I would like to make a strong recommendation against
load-time execution of code, if it can be at all avoided. Mac OS X and
Cocoa in particular have a strong bias in favor of lazy initialization,
for reasons of both performance and correctness. Load-time execution
generally is one of the most significant sources of non-portability,
binary incompatibility, unpredictable behavior, untraceable bugs, and
poor performance. If you must use it, then try especially to avoid any
source of dependencies on the order of initialization of different
executables.
Douglas Davidson
_______________________________________________
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.