<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Breaking change: Remove unqualified definitions &amp; new operator]]></title><description><![CDATA[<p dir="auto">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 <code>var</code> keyword. So this code:</p>
<pre><code class="language-javascript">var someFunkyVariable = 5;


/// hundreds of lines later
someFunkYVariable = 10;

// hundreds of lines later
if(someFunkyVariable == 5)
{
    CrashAndDeleteRootUser();
}

</code></pre>
<p dir="auto">will throw a script error at the second definition:</p>
<pre><code class="language-xml">Line 5, column 3:  Unqualified assignments are not supported anymore. Use `var` or `const var` or `reg` for definition
</code></pre>
<p dir="auto">. 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.</p>
<p dir="auto"><s>One caveat is that the standard <code>for</code> loop syntax</s></p>
<p dir="auto"><s>also throws an error message, because <code>i = 0</code> is a <strong>unqualified definition</strong>. The solution is to just define <code>i</code> once (or as local variable to be 100% thread-safe):</s></p>
<pre><code class="language-javascript">var i = 0;

for(i = 0; i &lt; 200; i++)
    doSomething();


for(i = 375; i &lt; 500; i++)
    doSomethingElse();


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 &lt; 200; i++)
        doSomething();
};

inline function runsOnThreadTwo()
{
    local i = 0;

    for(i = 0; i &lt; 200; i++)
        doSomethingElse()
};
</code></pre>
<p dir="auto">I also removed the <code>new</code> operator because it seducts people to use the weirder parts of the Javascript language.</p>
]]></description><link>https://forum.hise.audio/topic/366/breaking-change-remove-unqualified-definitions-new-operator</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 20:26:11 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/366.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Aug 2017 19:11:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Breaking change: Remove unqualified definitions &amp; new operator on Wed, 23 Aug 2017 21:15:21 GMT]]></title><description><![CDATA[<p dir="auto">OK, I admit the for loop thing was one bit too much, so I reverted this :)</p>
<p dir="auto">You can still use the standard <code>for(i = 0...</code> syntax...</p>
]]></description><link>https://forum.hise.audio/post/2315</link><guid isPermaLink="true">https://forum.hise.audio/post/2315</guid><dc:creator><![CDATA[Christoph Hart]]></dc:creator><pubDate>Wed, 23 Aug 2017 21:15:21 GMT</pubDate></item></channel></rss>