<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-SE" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<div>
<p class="MsoNormal"><span lang="SV">Hi!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="SV"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">We have found a tricky issue when moving over from Scilab 5 to Scilab 6 in my organization. We have a lot of code which works with nested lists, and functions modifying those lists. However, when a function is called
 with some nested lists as an input argument, the body of that function can change the value of the variable in the calling scope. This was not the case in Scilab 5, and the issue is super tricky to hunt down in our quite extensive code base. Below is a short
 example of the problem, and how to reproduce it.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I have also filed a bug report here: </span>
https://bugzilla.scilab.org/show_bug.cgi?id=16556<o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is anyone else seeing this problem? And do you have any workarounds or other suggestions?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Arvid<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">------<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">// Define variables<o:p></o:p></p>
<p class="MsoNormal">testArray = list();<o:p></o:p></p>
<p class="MsoNormal">for i=1:1:10<o:p></o:p></p>
<p class="MsoNormal">    testArray($+1) = list();<o:p></o:p></p>
<p class="MsoNormal">    for j=1:1:10<o:p></o:p></p>
<p class="MsoNormal">        testArray(i)($+1) = [];<o:p></o:p></p>
<p class="MsoNormal">        testArray(i)(j).testMember = 1;<o:p></o:p></p>
<p class="MsoNormal">    end<o:p></o:p></p>
<p class="MsoNormal">end<o:p></o:p></p>
<p class="MsoNormal">testArrayOrig = testArray;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">// Define functions<o:p></o:p></p>
<p class="MsoNormal">function outArray = testFunc(inArray)<o:p></o:p></p>
<p class="MsoNormal">    for i=1:1:10<o:p></o:p></p>
<p class="MsoNormal">        for j=1:1:10<o:p></o:p></p>
<p class="MsoNormal">            inArray(i)(j).testMember = 5<o:p></o:p></p>
<p class="MsoNormal">        end<o:p></o:p></p>
<p class="MsoNormal">    end<o:p></o:p></p>
<p class="MsoNormal">    outArray = inArray;<o:p></o:p></p>
<p class="MsoNormal">endfunction<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">// Send the variable as argument to the function<o:p></o:p></p>
<p class="MsoNormal">if %t<o:p></o:p></p>
<p class="MsoNormal">    testArrayOut = testFunc2(testArray);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    if testArrayOut(1)(1).testMember == testArray(1)(1).testMember<o:p></o:p></p>
<p class="MsoNormal">        error("Error! inputArgument was changed by function");<o:p></o:p></p>
<p class="MsoNormal">    end<o:p></o:p></p>
<p class="MsoNormal">end<o:p></o:p></p>
</div>
</div>
</body>
</html>