code-dot-org/blockly-core — pull request #80 by cpirich (2014-05-16 22:20:08+00:00)
Title: Variable scope

Add a new config parameter to blockly-core: varsInGlobals.

When this is set to true:
(1) variables are not defined at the top of the generated code.
(2) functions are defined as Globals.funcname = function () {} (instead of function funcname() {})
(3) variables are referenced as Globals.varname (instead of varname)

When generated code is invoked, a variable named Globals should passed in.

The reason for this is https://www.pivotaltracker.com/story/show/70326328 . Event based apps require blockly-core to generate code multiple times (once per event handler). We want the code executing in the event handlers to be able to share variables and eventually call functions. So this allows us to do this.