export keyword · Issue #121 · satyr/coco (original) (raw)
I was wondering if it'd be possible to add an export keyword. The reason is that in some JavaScript environments (hint hint, QtScript) people tend to require certain variable on the global scope. However, with the QtScript transition to V8, adding them to the "this" property will become a strict mode error if you don't use .call on a method, furthermore, many implementations don't posses a window-like object for the global scope.
The solution is to use the bare mode, but this isn't desirable. Instead I would propose the use of a special keyword, export.
a = 1
function randomNumber
...
export function eventAttacked victim, attacker
...
Might compile to:
var eventAttacked;
(function(){
var a;
eventAttacked = function (victim, attacker) { ... }
function randomNumber () { ... }
a = 1;
})();