Suppressing Unnecessary Messages
ambassador at fourthworld.com
Thu Oct 10 20:00:28 CEST 2013
> Does LiveCode engine send all possible messages constantly,
> regardless of that particular handler is implemented in the script or not?
> If I place a *mouseEnter* handler into the card script, that handler gets
> the message and does its thing.
> But if don't place any *mouseEnter* handler in any object, does the message
> still fire up?
> If yes,
> isn't this a waste of valuable resources?
Not so much. After all, most messages are sent in response to user
actions, and users are usually the slowest component in any computing
There are a few messages that are only sent when a handler exists in the
relevant object, such as idle and mouseWithin for example. Those types
of repeating messages can indeed eat up a lot of time (relatively
speaking) so they're not sent unless they're absolutely needed.
In fact, with both of those there are more efficient alternatives:
timers instead of idle, and mouseMove instead of mouseWithin.
It might be nice to see the engine become even smarter with messages,
but since messages aren't sent until an executing script has completed
(for the most part the engine uses single-threaded execution) it would
be relatively few cases where it would make a noticeable difference in
I suspect the bigger gains are to be found in the commands and functions
that are triggered by messages, which seems to be an ongoing interest by
the engine team.
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
More information about the use-livecode