<story><title>On VBScript</title><url>https://googleprojectzero.blogspot.com/2018/12/on-vbscript.html</url></story><parent_chain><item><author>tlb</author><text>VB&amp;#x27;s evaluation order, in which the left side of an assignment is evaluated before the right side, seems like a terrible idea. In most languages including C and C++, it&amp;#x27;s specified that the RHS is evaluated first. Since, of course, the RHS might have a side effect on the location of the LHS.&lt;p&gt;Is there some advantage to LHS-first that I can&amp;#x27;t think of?</text></item></parent_chain><comment><author>alangpierce</author><text>Interesting, my intuition is the opposite: that left-to-right evaluation is clearly the better approach. I just tested a few languages and it turns out that there&amp;#x27;s no clear agreed-upon answer, but LHS first seems to be more common at least for recent languages:&lt;p&gt;LHS first: JavaScript, Java, Go, C#, Swift, PHP, Ruby&lt;p&gt;RHS first: C++, Python, Rust&lt;p&gt;I ran this sort of code for all of them:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    def lhs(): print &amp;quot;LHS&amp;quot;; return 0
    def rhs(): print &amp;quot;RHS&amp;quot;; return 0
    a = [0]
    a[lhs()] = rhs()
&lt;/code&gt;&lt;/pre&gt;
&amp;quot;=&amp;quot; is syntactically just a binary operator, so I expect it to behave like other binary operators (and AFAIK all other binary operators evaluate left-to-right in almost all languages). It&amp;#x27;s special because the LHS evaluates to an assignable reference rather than to a value, but nothing stops you from evaluating the left side in full before starting to evaluate the right side. As with every binary operator, it&amp;#x27;s possible to write code such that the evaluation of one side affects the result of evaluating the other side, but of course that sort of code is really fragile anyway.</text></comment>
<story><title>On VBScript</title><url>https://googleprojectzero.blogspot.com/2018/12/on-vbscript.html</url></story><parent_chain><item><author>tlb</author><text>VB&amp;#x27;s evaluation order, in which the left side of an assignment is evaluated before the right side, seems like a terrible idea. In most languages including C and C++, it&amp;#x27;s specified that the RHS is evaluated first. Since, of course, the RHS might have a side effect on the location of the LHS.&lt;p&gt;Is there some advantage to LHS-first that I can&amp;#x27;t think of?</text></item></parent_chain><comment><author>userbinator</author><text>&lt;i&gt;including C and C++, it&amp;#x27;s specified that the RHS is evaluated first.&lt;/i&gt;&lt;p&gt;I did not check C++ but for C, according to ISO&amp;#x2F;IEC 9899:1999 section 6.5.16 paragraph 4 on the semantics of the assignment operator: &amp;quot;The order of evaluation of the operands is unspecified.&amp;quot;</text></comment>