<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>I think that this is a sufficiently serious issue to diserve a
report in bugzilla.scilab.org. But could you prepare a more
compact example ?</p>
<p>S.</p>
<div class="moz-cite-prefix">Le 16/10/2020 à 13:35, Arvid Rosén a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:11EEE9A2-23E6-47E5-96A1-AC3DD5561DA4@contoso.com">
<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;}size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}</style>
<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>
<a class="moz-txt-link-freetext" href="https://bugzilla.scilab.org/show_bug.cgi?id=16556">https://bugzilla.scilab.org/show_bug.cgi?id=16556</a><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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
</body>
</html>