When to use slot local variables?

One thing that has alluded me is slot local variables. I do not quite understand when to declare them. The example used in the developers manual is MIDI but when I looked at the code for the stock libraries it was used all over the place. Exactly how can you tell what parameters need to be declared as a slot local variable?

According to


“If some functions in your script depend on global variables that store the state of MIDI events, the automatic synchronization of global variables is usually a hindrance, because the global variables will be overwritten by the slot that received the latest MIDI events. To attain global variables that operate independently per slot, use defineSlotLocal.”

So in other words it is used if you have the same lua program in 2 or more slots and want them to independent global variables.