Board Thread:Support Requests - Getting Technical/@comment-23880286-20150719180003/@comment-24473195-20150719213028

Vogel100 wrote: So just to be clear, what is the best thing to do here?

It depends, if you're worried about performance. You should declare all your functions as local.

Make the functions local and move them up?

Personally I wouldn't use that route, forward declaration is better than moving things around.

Think of it this way, all this time you've been looking for a ghost bug, imagine another editor looking at your code.

Or make them global?

Generally speaking one should make everything local. But that's up to your coding style, and the complexity of the script/module.

And if I should make them global, should I do that in every module?

You should aim for consistency, regardless of the style of coding you decide. Although in some cases for performance or readability reasons you can throw out the book.

So I suppose I should just move them up?

The general idea is this:


 * Only add functions to p table that you want the user to use through invoke or require
 * Everything else should be a local either using forward declaration or whatever suits you.

Beware that the {{#invoke will also be able to access anything included in the p table.

P.S. We've been trying to create a style guide, but we still haven't figured out everything.