This is the basic idea.  Here's what the read me file says --

"These declares are not put into your application's import table, and so the system loader doesn't try to resolve them. Instead, when you first try to use the softly declared method, REALbasic is responsible for resolving the library and functions."

For MacOS X applications, Rb attempts to load the function pointer using CFBundle functions when the function is first called. I can guess how it's done for MacOS classic apps, and have no idea how it's done in Windows and Linux applications. In all cases, I believe that the function pointer is cached for reuse.

Even so, my testing suggests a slight performance hit when using soft declares; I assume that there is a bit more indirection involved in calling such functions. If you're calling a soft-declared function 100,000 times in a loop, this is something to consider. Otherwise, the flexibility afforded by them outweighs this cost in performance.

Charles Yeomans

On Apr 1, 2006, at 2:16 PM, E. Tejkowski wrote:

Correct me if I'm wrong Charles, because I've not used soft declares much, but isn't the basic idea that declares let you use libraries that are known at compile time, whereas soft declares let you use libraries that aren't known until runtime? I think that helps explain your Windows remark, for example. Normally when you compile, you say "hey RB, don't forget to include THIS library in the list of libraries you know about when compiling my app". With soft declares, (I think) it's like saying "hey RB, you don't know about this library yet, but one will be forthcoming when this app starts running". And that's why you can target both unicode and ANSI in one app. The app can decide at runtime which to use, while the "hard" declare inserts the reference to a specific library when you compile (and is "set in stone", so to speak). Sorry if I'm overanalyzing, but this topic is new for me too. I want to make sure I know what this is about. :-)

Erick

On Apr 1, 2006, at 12:19 PM, Charles Yeomans wrote:


On Apr 1, 2006, at 12:27 AM, Keith Hutchison wrote:

I'm looking for a summary for the benefits of soft declares in RB 2005/2006.


You can find one in chapter 2 of my book on declares <http:// www.declareSub.com/>. Here is a summary of the summary:

Functions not actually in libraries result in exceptions at runtime instead of a launch failure or mysterious abrupt exit.

MacOS -- PEF apps can call Mach-O frameworks, thus making it possible for Joe Strout to continue to compile to his favorite executable format. It is now possible to write Carbon apps that run in both MacOS X and MacOS 9 in all cases.

Windows -- can call both unicode and ANSI versions of functions depending on platform in one app, instead of having to build a version for each Windows variety.

Linux -- soft declares can resolve loader scripts, thus giving apps a better shot at working under a Linux install other than your own.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to