Changes between Version 2 and Version 15 of Ticket #2322


Ignore:
Timestamp:
Aug 29, 2019, 5:49:58 PM (5 years ago)
Author:
elexis
Comment:

A grep for "module" on that month brings up the following related discussions:

2013-12-14-QuakeNet-#0ad-dev.log:11:23 < Yves`> the code will have to be wrapped in some kind of module pattern to avoid naming conflicts between different AI scripts: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html

2013-12-15-QuakeNet-#0ad-dev.log:14:16 < Yves`> wraitii: Even if it makes a little difference, I would still care about other problems more because the whole map-module should be moved to C++ anyway

2013-12-18-QuakeNet-#0ad-dev.log:16:14 < Yves> what does "Map.createObstructionMap = function ..." in aegis/map-module.js exactly do?

2013-12-28-QuakeNet-#0ad-dev.log:16:51 < Yves`> but qbot isn't moved to a module and still uses the global scope

2013-12-29-QuakeNet-#0ad-dev.log:14:49 < Yves`> yes I actually didn't want to change all the old AIs. I've only moved Aegis and common-api-v3 to a module, left qbot in the global scope and didn't test any other AIs

So the patch that this problem aims to solve is:

11:21 < Yves`> there's one ScriptInterface with an own global object for each AI players

on 30th december 2013:

01:30 < Philip`> Yves`: (It would perhaps be nice if we could use the ES6 module system to import/export things instead of requiring a "m." prefix thing, but I guess we need to wait for SpiderMonkey to implement that first, and need to upgrade to that SpiderMonkey :-) )

refs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

The commit (r14441) triggers an ESLint warning: https://eslint.org/docs/rules/no-use-before-define

In JavaScript, prior to ES6, variable and function declarations are hoisted to the top of a scope, so it’s possible to use identifiers before their formal declarations in code. This can be confusing and some believe it is best to always declare variables and functions before using them.

So the var foo = function() { return bar; }(foo); code was misleading because foo was once said to be defined to a value at the beginning var foo but in reality is created prior to it due to hoisting when the function value is resolved.

The patch at Phab:D2103 attempts to fix it by deleting the Augmentation pattern which wasn't used (no function arguments, no private arguments).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2322

    • Property Status newclosed
    • Property Summary Move all AI players to one global[PATCH] Move all AI players to one global
    • Property Owner set to Yves
    • Property Resolutionfixed