Breaking change: Remove unqualified definitions & new operator

  • I've been working on the scripting engine for the last days (implementing proper callstacks and local variable dumps when using breakpoints). As a side effect of these efforts, I've removed the possibility to define global variables without the var keyword. So this code:

    var someFunkyVariable = 5;
    /// hundreds of lines later
    someFunkYVariable = 10;
    // hundreds of lines later
    if(someFunkyVariable == 5)

    will throw a script error at the second definition:

    Line 5, column 3:  Unqualified assignments are not supported anymore. Use `var` or `const var` or `reg` for definition

    . This will help to avoid nasty bugs which are extremely annoying to track down (plus enforce a better coding style). This however is not standard Javascript behaviour (but there is a dialect of Javascript called "strict" Javascript which does the same thing.

    One caveat is that the standard for loop syntax

    also throws an error message, because i = 0 is a unqualified definition. The solution is to just define i once (or as local variable to be 100% thread-safe):

    var i = 0;
    for(i = 0; i < 200; i++)
    for(i = 375; i < 500; i++)
    inline function runsOnThreadOne()
        // Using local variables makes sure that the iterator value is not
        // changed by the other thread
        local i = 0;
        for(i = 0; i < 200; i++)
    inline function runsOnThreadTwo()
        local i = 0;
        for(i = 0; i < 200; i++)

    I also removed the new operator because it seducts people to use the weirder parts of the Javascript language.

  • OK, I admit the for loop thing was one bit too much, so I reverted this 🙂

    You can still use the standard for(i = 0... syntax...

Log in to reply