Ender Nafi wrote:

Is there any difference, especially performance-wise, between these two 
approaches:

1. Library code is in the library stack’s script and it’s activated by
_start using stack “libraryCode”

2. Library code is distributed to different buttons of a card of the main stack 
and it’s activated by
_repeat with x=1 to the number of buttons of card “libraryCode”
__insert the script of button x of card “libraryCode” into back
_end repeat

I haven't measured that but I would expect any difference to be inconsequential.

Access to handlers in behaviors measures slightly faster than in libraries, but this modest speed bump is possible because of their more limited scope so plan accordingly.

FWIW, remember that even backscripts and libraries can use behaviors, and behavior can be chained as of v6.1, so if it helps clarify your design to think of the scripts as classes and subclasses this is now a powerful new option available to us.

Using behaviors attached to backScripts may give you the greatest balance of flexibility and performance, depending on the particulars of your setup.

I wouldn't recommend using behaviors solely for the speed bump, as it's only a few microseconds. But where behaviors can clarify your design, where limiting scope can be beneficial, it's great that we have them and can now nest them.

--
 Richard Gaskin
 Fourth World
 LiveCode training and consulting: http://www.fourthworld.com
 Webzine for LiveCode developers: http://www.LiveCodeJournal.com
 Follow me on Twitter:  http://twitter.com/FourthWorldSys

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to